Added pw reset jwt generation

ref #40
This commit is contained in:
Nicolai Ort 2020-12-22 10:24:25 +01:00
parent b6cf3b24d4
commit 6042089074
1 changed files with 14 additions and 0 deletions

View File

@ -33,6 +33,20 @@ export class JwtCreator {
exp: expiry_timestamp
}, config.jwt_secret)
}
/**
* Creates a new password reset token for a given user.
* The token is valid for 15 minutes or 1 use - whatever comes first.
* @param user User entity that the password reset token shall be created for
*/
public static createReset(user: User) {
let expiry_timestamp = Math.floor(Date.now() / 1000) + 10 * 36000;
return jsonwebtoken.sign({
id: user.id,
refreshTokenCount: user.refreshTokenCount,
exp: expiry_timestamp
}, config.jwt_secret)
}
}
/**