parent
28c2b862f0
commit
c33097f773
@ -32,14 +32,22 @@ export class CreateAuth {
|
|||||||
throw new UserNotFoundError()
|
throw new UserNotFoundError()
|
||||||
} else {
|
} else {
|
||||||
const found_user = found_users[0]
|
const found_user = found_users[0]
|
||||||
console.log(found_user.password);
|
|
||||||
if (await argon2.verify(found_user.password, this.password + found_user.uuid)) {
|
if (await argon2.verify(found_user.password, this.password + found_user.uuid)) {
|
||||||
// TODO: proper jwt creation
|
// TODO: proper jwt creation
|
||||||
const token = jsonwebtoken.sign({}, "securekey")
|
const timestamp_accesstoken_expiry = Math.floor(Date.now() / 1000) + 5 * 60
|
||||||
newAuth.access_token = token
|
newAuth.access_token = jsonwebtoken.sign({
|
||||||
newAuth.refresh_token = token
|
refreshtokencount: 5,
|
||||||
newAuth.access_token_expires_at = 1587349200
|
userdetails: {},
|
||||||
newAuth.refresh_token_expires_at = 1587349200
|
exp: timestamp_accesstoken_expiry
|
||||||
|
}, "securekey")
|
||||||
|
const timestamp_refresh_expiry = Math.floor(Date.now() / 1000) + 10 * 36000
|
||||||
|
newAuth.refresh_token = jsonwebtoken.sign({
|
||||||
|
refreshtokencount: 5,
|
||||||
|
userdetails: {},
|
||||||
|
exp: timestamp_refresh_expiry
|
||||||
|
}, "securekey")
|
||||||
|
newAuth.access_token_expires_at = timestamp_accesstoken_expiry
|
||||||
|
newAuth.refresh_token_expires_at = timestamp_refresh_expiry
|
||||||
} else {
|
} else {
|
||||||
throw new InvalidCredentialsError()
|
throw new InvalidCredentialsError()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user