aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/redis.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-08-12 09:15:31 +0200
committerChocobozzz <me@florianbigard.com>2020-08-12 09:16:08 +0200
commite9c5f123383e461a890c95368dce6f79d3b84660 (patch)
treeb6c55e9572a3566d4f2defbff314ac8414be8212 /server/lib/redis.ts
parent857961f0ee39f90dc3267cebd2b5e3f718115d06 (diff)
downloadPeerTube-e9c5f123383e461a890c95368dce6f79d3b84660.tar.gz
PeerTube-e9c5f123383e461a890c95368dce6f79d3b84660.tar.zst
PeerTube-e9c5f123383e461a890c95368dce6f79d3b84660.zip
Do not reuse reset password links
Diffstat (limited to 'server/lib/redis.ts')
-rw-r--r--server/lib/redis.ts14
1 files changed, 14 insertions, 0 deletions
diff --git a/server/lib/redis.ts b/server/lib/redis.ts
index 5313c4685..a075eee2d 100644
--- a/server/lib/redis.ts
+++ b/server/lib/redis.ts
@@ -84,6 +84,10 @@ class Redis {
84 return generatedString 84 return generatedString
85 } 85 }
86 86
87 async removePasswordVerificationString (userId: number) {
88 return this.removeValue(this.generateResetPasswordKey(userId))
89 }
90
87 async getResetPasswordLink (userId: number) { 91 async getResetPasswordLink (userId: number) {
88 return this.getValue(this.generateResetPasswordKey(userId)) 92 return this.getValue(this.generateResetPasswordKey(userId))
89 } 93 }
@@ -290,6 +294,16 @@ class Redis {
290 }) 294 })
291 } 295 }
292 296
297 private removeValue (key: string) {
298 return new Promise<void>((res, rej) => {
299 this.client.del(this.prefix + key, err => {
300 if (err) return rej(err)
301
302 return res()
303 })
304 })
305 }
306
293 private setObject (key: string, obj: { [id: string]: string }, expirationMilliseconds: number) { 307 private setObject (key: string, obj: { [id: string]: string }, expirationMilliseconds: number) {
294 return new Promise<void>((res, rej) => { 308 return new Promise<void>((res, rej) => {
295 this.client.hmset(this.prefix + key, obj, (err, ok) => { 309 this.client.hmset(this.prefix + key, obj, (err, ok) => {