remove expiration argument

This commit is contained in:
deflax 2024-04-03 18:21:53 +03:00
parent 2c100e079a
commit 9b4d98e3d9

View file

@ -1,5 +1,6 @@
from werkzeug.security import generate_password_hash, check_password_hash from werkzeug.security import generate_password_hash, check_password_hash
from itsdangerous.url_safe import URLSafeTimedSerializer as Serializer from itsdangerous.url_safe import URLSafeTimedSerializer as Serializer
from itsdangerous.exc import BadSignature, SignatureExpired
from flask import current_app, request, url_for from flask import current_app, request, url_for
from flask_sqlalchemy import SQLAlchemy from flask_sqlalchemy import SQLAlchemy
@ -123,8 +124,8 @@ class User(db.Model, UserMixin):
def verify_totp(self, token): def verify_totp(self, token):
return onetimepass.valid_totp(token, self.otp_secret) return onetimepass.valid_totp(token, self.otp_secret)
def generate_confirmation_token(self, expiration=86400): def generate_confirmation_token(self):
s = Serializer(current_app.config['SECRET_KEY'], expiration) s = Serializer(current_app.config['SECRET_KEY'])
return s.dumps({'confirm': self.id}) return s.dumps({'confirm': self.id})
def confirm(self, token): def confirm(self, token):
@ -140,8 +141,8 @@ class User(db.Model, UserMixin):
db.session.commit() db.session.commit()
return True return True
def generate_reset_token(self, expiration=86400): def generate_reset_token(self):
s = Serializer(current_app.config['SECRET_KEY'], expiration) s = Serializer(current_app.config['SECRET_KEY'])
return s.dumps({'reset': self.id}) return s.dumps({'reset': self.id})
def reset_password(self, token, new_password): def reset_password(self, token, new_password):