Commit 615da07f0b8ec79c4bbc801d1b9d27d8d9a1c372

Authored by hitier
1 parent 4770ee5d

Fix set_role and and set_password to User.init

Showing 1 changed file with 6 additions and 1 deletions   Show diff stats
app/auth/models.py
... ... @@ -49,6 +49,7 @@ class User(UserMixin, db.Model):
49 49 name = db.Column(db.String(100))
50 50 login = db.Column(db.String(100), unique=True)
51 51 role = db.Column(db.Integer, default=0)
  52 + password = db.Column(db.String(128))
52 53 password_hash = db.Column(db.String(128))
53 54  
54 55 def __repr__(self):
... ... @@ -57,7 +58,11 @@ class User(UserMixin, db.Model):
57 58 # Set role at construction time
58 59 def __init__(self, **kwargs):
59 60 super(User, self).__init__(**kwargs)
60   - self.set_role(kwargs['role'])
  61 + if ('role' in kwargs):
  62 + self.set_role(kwargs['role'])
  63 + if ('password' in kwargs):
  64 + self.set_password(kwargs['password'])
  65 + self.password = None
61 66  
62 67 def set_role(self, role):
63 68 self.role = _checkRole(role)
... ...