return generatedString
}
+ async removePasswordVerificationString (userId: number) {
+ return this.removeValue(this.generateResetPasswordKey(userId))
+ }
+
async getResetPasswordLink (userId: number) {
return this.getValue(this.generateResetPasswordKey(userId))
}
})
}
+ private removeValue (key: string) {
+ return new Promise<void>((res, rej) => {
+ this.client.del(this.prefix + key, err => {
+ if (err) return rej(err)
+
+ return res()
+ })
+ })
+ }
+
private setObject (key: string, obj: { [id: string]: string }, expirationMilliseconds: number) {
return new Promise<void>((res, rej) => {
this.client.hmset(this.prefix + key, obj, (err, ok) => {
await resetPassword(server.url, userId, verificationString, 'super_password2')
})
+ it('Should not reset the password with the same verification string', async function () {
+ await resetPassword(server.url, userId, verificationString, 'super_password3', 403)
+ })
+
it('Should login with this new password', async function () {
user.password = 'super_password2'