aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/user/user.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/models/user/user.ts
parentbc48e33b80f357767b98c1d310b04bdda24c6d46 (diff)
downloadPeerTube-e364e31e25bd1d4b8d801c845a96d6be708f0a18.tar.gz
PeerTube-e364e31e25bd1d4b8d801c845a96d6be708f0a18.tar.zst
PeerTube-e364e31e25bd1d4b8d801c845a96d6be708f0a18.zip
Implement signup approval in server
Diffstat (limited to 'server/models/user/user.ts')
-rw-r--r--server/models/user/user.ts17
1 files changed, 9 insertions, 8 deletions
diff --git a/server/models/user/user.ts b/server/models/user/user.ts
index 0932a367a..c5c8a1b30 100644
--- a/server/models/user/user.ts
+++ b/server/models/user/user.ts
@@ -441,16 +441,17 @@ export class UserModel extends Model<Partial<AttributesOnly<UserModel>>> {
441 }) 441 })
442 OAuthTokens: OAuthTokenModel[] 442 OAuthTokens: OAuthTokenModel[]
443 443
444 // Used if we already set an encrypted password in user model
445 skipPasswordEncryption = false
446
444 @BeforeCreate 447 @BeforeCreate
445 @BeforeUpdate 448 @BeforeUpdate
446 static cryptPasswordIfNeeded (instance: UserModel) { 449 static async cryptPasswordIfNeeded (instance: UserModel) {
447 if (instance.changed('password') && instance.password) { 450 if (instance.skipPasswordEncryption) return
448 return cryptPassword(instance.password) 451 if (!instance.changed('password')) return
449 .then(hash => { 452 if (!instance.password) return
450 instance.password = hash 453
451 return undefined 454 instance.password = await cryptPassword(instance.password)
452 })
453 }
454 } 455 }
455 456
456 @AfterUpdate 457 @AfterUpdate