parent
126799dab9
commit
51addd4a31
@ -20,7 +20,6 @@ export class RefreshAuth {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new IllegalJWTError()
|
throw new IllegalJWTError()
|
||||||
}
|
}
|
||||||
console.log(decoded["userid"]);
|
|
||||||
const found_user = await getConnectionManager().get().getRepository(User).findOne({ id: decoded["userid"] });
|
const found_user = await getConnectionManager().get().getRepository(User).findOne({ id: decoded["userid"] });
|
||||||
if (!found_user) {
|
if (!found_user) {
|
||||||
throw new UserNotFoundError()
|
throw new UserNotFoundError()
|
||||||
@ -28,12 +27,22 @@ export class RefreshAuth {
|
|||||||
if (found_user.refreshTokenCount !== decoded["refreshtokencount"]) {
|
if (found_user.refreshTokenCount !== decoded["refreshtokencount"]) {
|
||||||
throw new RefreshTokenCountInvalidError()
|
throw new RefreshTokenCountInvalidError()
|
||||||
}
|
}
|
||||||
console.log(found_user);
|
delete found_user.password;
|
||||||
// delete found_user.password;
|
const timestamp_accesstoken_expiry = Math.floor(Date.now() / 1000) + 5 * 60
|
||||||
newAuth.access_token = "ja"
|
delete found_user.password;
|
||||||
newAuth.access_token_expires_at = 5555555
|
newAuth.access_token = jsonwebtoken.sign({
|
||||||
newAuth.refresh_token = "ja"
|
userdetails: found_user,
|
||||||
newAuth.refresh_token_expires_at = 555555
|
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: found_user.refreshTokenCount,
|
||||||
|
userid: found_user.id,
|
||||||
|
exp: timestamp_refresh_expiry
|
||||||
|
}, "securekey")
|
||||||
|
newAuth.refresh_token_expires_at = timestamp_refresh_expiry
|
||||||
|
|
||||||
return newAuth;
|
return newAuth;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user