added a lot of auth code
This commit is contained in:
@@ -102,6 +102,20 @@ class User(UserMixin, db.Model):
|
||||
"""
|
||||
return re.sub('[^a-zA-Z0-9_.]', '', nickname)
|
||||
|
||||
@classmethod
|
||||
def authenticate(cls, **kwargs):
|
||||
email = kwargs.get('email')
|
||||
password = kwargs.get('password')
|
||||
|
||||
if not email or not password:
|
||||
return None
|
||||
|
||||
user = cls.query.filter_by(email=email).first()
|
||||
if not user or not user.verify_password(password):
|
||||
return None
|
||||
|
||||
return user
|
||||
|
||||
@property
|
||||
def is_authenticated(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user