mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
Add reset token generation functionality in User class.
This commit is contained in:
parent
ed921b68d7
commit
4ef5b480b1
@ -1,4 +1,6 @@
|
|||||||
|
from flask import current_app
|
||||||
from flask_login import UserMixin
|
from flask_login import UserMixin
|
||||||
|
from itsdangerous import TimedJSONWebSignatureSerializer as Serializer
|
||||||
from werkzeug.security import generate_password_hash, check_password_hash
|
from werkzeug.security import generate_password_hash, check_password_hash
|
||||||
from . import db
|
from . import db
|
||||||
from . import login_manager
|
from . import login_manager
|
||||||
@ -26,6 +28,10 @@ class User(UserMixin, db.Model):
|
|||||||
|
|
||||||
password_hash = db.Column(db.String(128))
|
password_hash = db.Column(db.String(128))
|
||||||
|
|
||||||
|
def generate_reset_token(self, expiration=3600):
|
||||||
|
s = Serializer(current_app.config['SECRET_KEY'], expiration)
|
||||||
|
return s.dumps({'reset': self.id}).decode('utf-8')
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def password(self):
|
def password(self):
|
||||||
raise AttributeError('password is not a readable attribute')
|
raise AttributeError('password is not a readable attribute')
|
||||||
|
Loading…
Reference in New Issue
Block a user