]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/account/user.ts
Add auth plugin info in users list
[github/Chocobozzz/PeerTube.git] / server / models / account / user.ts
index da40bf290ad43e87b870607d3e93a5f60d8fcd25..260c1b28eba443921817f28a31ab01cb17b4aef6 100644 (file)
@@ -221,8 +221,8 @@ enum ScopeNames {
 })
 export class UserModel extends Model<UserModel> {
 
-  @AllowNull(false)
-  @Is('UserPassword', value => throwIfNotValid(value, isUserPasswordValid, 'user password'))
+  @AllowNull(true)
+  @Is('UserPassword', value => throwIfNotValid(value, isUserPasswordValid, 'user password', true))
   @Column
   password: string
 
@@ -348,6 +348,11 @@ export class UserModel extends Model<UserModel> {
   @Column
   noWelcomeModal: boolean
 
+  @AllowNull(true)
+  @Default(null)
+  @Column
+  pluginAuth: string
+
   @CreatedAt
   createdAt: Date
 
@@ -383,7 +388,7 @@ export class UserModel extends Model<UserModel> {
   @BeforeCreate
   @BeforeUpdate
   static cryptPasswordIfNeeded (instance: UserModel) {
-    if (instance.changed('password')) {
+    if (instance.changed('password') && instance.password) {
       return cryptPassword(instance.password)
         .then(hash => {
           instance.password = hash
@@ -801,7 +806,9 @@ export class UserModel extends Model<UserModel> {
 
       videoChannels: [],
 
-      createdAt: this.createdAt
+      createdAt: this.createdAt,
+
+      pluginAuth: this.pluginAuth
     }
 
     if (parameters.withAdminFlags) {