🚧 CreateAuth now returns a sample jwt

ref #12
This commit is contained in:
Philipp Dormann 2020-12-05 11:14:26 +01:00
parent b8bc39d691
commit d46ad59546
1 changed files with 3 additions and 5 deletions

View File

@ -12,6 +12,7 @@ export class CreateAuth {
username?: string;
@IsString()
password: string;
@IsOptional()
@IsEmail()
@IsString()
email?: string;
@ -26,20 +27,17 @@ export class CreateAuth {
throw new PasswordNeededError()
}
const found_users = await getConnectionManager().get().getRepository(User).find({ where: [{ username: this.username }, { email: this.email }] });
console.log(found_users);
if (found_users.length === 0) {
throw new UserNotFoundError()
} else {
const found_user = found_users[0]
const token = jsonwebtoken.sign(found_user, "sec")
// TODO: jwt creation
// TODO: proper jwt creation
const token = jsonwebtoken.sign({}, "securekey")
newAuth.access_token = token
newAuth.refresh_token = token
newAuth.access_token_expires_at = 1587349200
newAuth.refresh_token_expires_at = 1587349200
console.log(newAuth)
}
return newAuth;
}