aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/redis.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-01-19 09:27:16 +0100
committerChocobozzz <chocobozzz@cpy.re>2023-01-19 13:53:40 +0100
commite364e31e25bd1d4b8d801c845a96d6be708f0a18 (patch)
tree220785a42af361706eb8243960c5da9cddf4d2be /server/lib/redis.ts
parentbc48e33b80f357767b98c1d310b04bdda24c6d46 (diff)
downloadPeerTube-e364e31e25bd1d4b8d801c845a96d6be708f0a18.tar.gz
PeerTube-e364e31e25bd1d4b8d801c845a96d6be708f0a18.tar.zst
PeerTube-e364e31e25bd1d4b8d801c845a96d6be708f0a18.zip
Implement signup approval in server
Diffstat (limited to 'server/lib/redis.ts')
-rw-r--r--server/lib/redis.ts30
1 files changed, 23 insertions, 7 deletions
diff --git a/server/lib/redis.ts b/server/lib/redis.ts
index 451ddd0b6..3706d2228 100644
--- a/server/lib/redis.ts
+++ b/server/lib/redis.ts
@@ -9,7 +9,7 @@ import {
9 CONTACT_FORM_LIFETIME, 9 CONTACT_FORM_LIFETIME,
10 RESUMABLE_UPLOAD_SESSION_LIFETIME, 10 RESUMABLE_UPLOAD_SESSION_LIFETIME,
11 TWO_FACTOR_AUTH_REQUEST_TOKEN_LIFETIME, 11 TWO_FACTOR_AUTH_REQUEST_TOKEN_LIFETIME,
12 USER_EMAIL_VERIFY_LIFETIME, 12 EMAIL_VERIFY_LIFETIME,
13 USER_PASSWORD_CREATE_LIFETIME, 13 USER_PASSWORD_CREATE_LIFETIME,
14 USER_PASSWORD_RESET_LIFETIME, 14 USER_PASSWORD_RESET_LIFETIME,
15 VIEW_LIFETIME, 15 VIEW_LIFETIME,
@@ -124,16 +124,28 @@ class Redis {
124 124
125 /* ************ Email verification ************ */ 125 /* ************ Email verification ************ */
126 126
127 async setVerifyEmailVerificationString (userId: number) { 127 async setUserVerifyEmailVerificationString (userId: number) {
128 const generatedString = await generateRandomString(32) 128 const generatedString = await generateRandomString(32)
129 129
130 await this.setValue(this.generateVerifyEmailKey(userId), generatedString, USER_EMAIL_VERIFY_LIFETIME) 130 await this.setValue(this.generateUserVerifyEmailKey(userId), generatedString, EMAIL_VERIFY_LIFETIME)
131 131
132 return generatedString 132 return generatedString
133 } 133 }
134 134
135 async getVerifyEmailLink (userId: number) { 135 async getUserVerifyEmailLink (userId: number) {
136 return this.getValue(this.generateVerifyEmailKey(userId)) 136 return this.getValue(this.generateUserVerifyEmailKey(userId))
137 }
138
139 async setRegistrationVerifyEmailVerificationString (registrationId: number) {
140 const generatedString = await generateRandomString(32)
141
142 await this.setValue(this.generateRegistrationVerifyEmailKey(registrationId), generatedString, EMAIL_VERIFY_LIFETIME)
143
144 return generatedString
145 }
146
147 async getRegistrationVerifyEmailLink (registrationId: number) {
148 return this.getValue(this.generateRegistrationVerifyEmailKey(registrationId))
137 } 149 }
138 150
139 /* ************ Contact form per IP ************ */ 151 /* ************ Contact form per IP ************ */
@@ -346,8 +358,12 @@ class Redis {
346 return 'two-factor-request-' + userId + '-' + token 358 return 'two-factor-request-' + userId + '-' + token
347 } 359 }
348 360
349 private generateVerifyEmailKey (userId: number) { 361 private generateUserVerifyEmailKey (userId: number) {
350 return 'verify-email-' + userId 362 return 'verify-email-user-' + userId
363 }
364
365 private generateRegistrationVerifyEmailKey (registrationId: number) {
366 return 'verify-email-registration-' + registrationId
351 } 367 }
352 368
353 private generateIPViewKey (ip: string, videoUUID: string) { 369 private generateIPViewKey (ip: string, videoUUID: string) {