mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-24 10:34:17 +00:00
Codestyle and new python package versions.
This commit is contained in:
parent
bfe28eca61
commit
19f60cfd0f
@ -1,6 +1,6 @@
|
|||||||
from flask import current_app
|
from flask import current_app
|
||||||
from flask_login import UserMixin, AnonymousUserMixin
|
from flask_login import UserMixin, AnonymousUserMixin
|
||||||
from itsdangerous import TimedJSONWebSignatureSerializer as Serializer
|
from itsdangerous import BadSignature, TimedJSONWebSignatureSerializer
|
||||||
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
|
||||||
@ -22,8 +22,8 @@ class Permission:
|
|||||||
|
|
||||||
class Role(db.Model):
|
class Role(db.Model):
|
||||||
"""
|
"""
|
||||||
Model for the different roles Users can have. Is a one-to-many relationship.
|
Model for the different roles Users can have. Is a one-to-many
|
||||||
A Role can be associated with many User rows.
|
relationship. A Role can be associated with many User rows.
|
||||||
"""
|
"""
|
||||||
__tablename__ = 'roles'
|
__tablename__ = 'roles'
|
||||||
# Primary key
|
# Primary key
|
||||||
@ -136,24 +136,26 @@ class User(UserMixin, db.Model):
|
|||||||
"""
|
"""
|
||||||
Generates a confirmation token for user confirmation via email.
|
Generates a confirmation token for user confirmation via email.
|
||||||
"""
|
"""
|
||||||
s = Serializer(current_app.config['SECRET_KEY'], expiration)
|
s = TimedJSONWebSignatureSerializer(current_app.config['SECRET_KEY'],
|
||||||
|
expiration)
|
||||||
return s.dumps({'confirm': self.id}).decode('utf-8')
|
return s.dumps({'confirm': self.id}).decode('utf-8')
|
||||||
|
|
||||||
def generate_reset_token(self, expiration=3600):
|
def generate_reset_token(self, expiration=3600):
|
||||||
"""
|
"""
|
||||||
Generates a reset token for password reset via email.
|
Generates a reset token for password reset via email.
|
||||||
"""
|
"""
|
||||||
s = Serializer(current_app.config['SECRET_KEY'], expiration)
|
s = TimedJSONWebSignatureSerializer(current_app.config['SECRET_KEY'],
|
||||||
|
expiration)
|
||||||
return s.dumps({'reset': self.id}).decode('utf-8')
|
return s.dumps({'reset': self.id}).decode('utf-8')
|
||||||
|
|
||||||
def confirm(self, token):
|
def confirm(self, token):
|
||||||
"""
|
"""
|
||||||
Confirms User if the given token is valid and not expired.
|
Confirms User if the given token is valid and not expired.
|
||||||
"""
|
"""
|
||||||
s = Serializer(current_app.config['SECRET_KEY'])
|
s = TimedJSONWebSignatureSerializer(current_app.config['SECRET_KEY'])
|
||||||
try:
|
try:
|
||||||
data = s.loads(token.encode('utf-8'))
|
data = s.loads(token.encode('utf-8'))
|
||||||
except:
|
except BadSignature:
|
||||||
return False
|
return False
|
||||||
if data.get('confirm') != self.id:
|
if data.get('confirm') != self.id:
|
||||||
return False
|
return False
|
||||||
@ -166,10 +168,10 @@ class User(UserMixin, db.Model):
|
|||||||
"""
|
"""
|
||||||
Resets password for User if the given token is valid and not expired.
|
Resets password for User if the given token is valid and not expired.
|
||||||
"""
|
"""
|
||||||
s = Serializer(current_app.config['SECRET_KEY'])
|
s = TimedJSONWebSignatureSerializer(current_app.config['SECRET_KEY'])
|
||||||
try:
|
try:
|
||||||
data = s.loads(token.encode('utf-8'))
|
data = s.loads(token.encode('utf-8'))
|
||||||
except:
|
except BadSignature:
|
||||||
return False
|
return False
|
||||||
user = User.query.get(data.get('reset'))
|
user = User.query.get(data.get('reset'))
|
||||||
if user is None:
|
if user is None:
|
||||||
@ -291,6 +293,7 @@ class Corpus(db.Model):
|
|||||||
'title': self.title,
|
'title': self.title,
|
||||||
'user_id': self.user_id}
|
'user_id': self.user_id}
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
' Flask-Login is told to use the application’s custom anonymous user by setting
|
' Flask-Login is told to use the application’s custom anonymous user by setting
|
||||||
' its class in the login_manager.anonymous_user attribute.
|
' its class in the login_manager.anonymous_user attribute.
|
||||||
|
@ -33,7 +33,8 @@ class Config:
|
|||||||
|
|
||||||
class DevelopmentConfig(Config):
|
class DevelopmentConfig(Config):
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'data_dev.sqlite')
|
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir,
|
||||||
|
'data_dev.sqlite')
|
||||||
|
|
||||||
|
|
||||||
class TestingConfig(Config):
|
class TestingConfig(Config):
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
docker==4.0.2
|
docker
|
||||||
eventlet==0.25.0
|
eventlet
|
||||||
Flask==1.0.3
|
Flask
|
||||||
Flask-APScheduler==1.11.0
|
Flask-APScheduler
|
||||||
Flask-Login==0.4.1
|
Flask-Login
|
||||||
Flask-Mail==0.9.1
|
Flask-Mail
|
||||||
Flask-Migrate==2.5.2
|
Flask-Migrate
|
||||||
Flask-SocketIO==4.2.1
|
Flask-SocketIO
|
||||||
Flask-SQLAlchemy==2.4.0
|
Flask-SQLAlchemy
|
||||||
Flask-Table==0.5.0
|
Flask-Table
|
||||||
Flask-WTF==0.14.2
|
Flask-WTF
|
||||||
python-dotenv==0.10.3
|
python-dotenv
|
||||||
|
Loading…
Reference in New Issue
Block a user