parent
b8bc39d691
commit
d46ad59546
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue