🚧 CreateAuth - basic jwt creation with user details

ref #12
This commit is contained in:
Philipp Dormann 2020-12-05 12:34:07 +01:00
parent c33097f773
commit a0fe8c0017
1 changed files with 5 additions and 5 deletions

View File

@ -33,20 +33,20 @@ export class CreateAuth {
} else {
const found_user = found_users[0]
if (await argon2.verify(found_user.password, this.password + found_user.uuid)) {
// TODO: proper jwt creation
const timestamp_accesstoken_expiry = Math.floor(Date.now() / 1000) + 5 * 60
delete found_user.password;
newAuth.access_token = jsonwebtoken.sign({
refreshtokencount: 5,
userdetails: {},
userdetails: found_user,
exp: timestamp_accesstoken_expiry
}, "securekey")
newAuth.access_token_expires_at = timestamp_accesstoken_expiry
//
const timestamp_refresh_expiry = Math.floor(Date.now() / 1000) + 10 * 36000
newAuth.refresh_token = jsonwebtoken.sign({
refreshtokencount: 5,
userdetails: {},
userid: found_user.id,
exp: timestamp_refresh_expiry
}, "securekey")
newAuth.access_token_expires_at = timestamp_accesstoken_expiry
newAuth.refresh_token_expires_at = timestamp_refresh_expiry
} else {
throw new InvalidCredentialsError()