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