From e805a4eeab96d01fc24b7215bdef8c63a77e8934 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Wed, 19 Nov 2014 21:36:45 +0100 Subject: Bug fix: activation key was too long for the database column. --- pyaggr3g470r/models.py | 4 ++-- pyaggr3g470r/views.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'pyaggr3g470r') diff --git a/pyaggr3g470r/models.py b/pyaggr3g470r/models.py index 3e3f76d4..f7052ed5 100644 --- a/pyaggr3g470r/models.py +++ b/pyaggr3g470r/models.py @@ -45,10 +45,10 @@ class User(db.Model, UserMixin): email = db.Column(db.String(254), index = True, unique = True) pwdhash = db.Column(db.String()) roles = db.relationship('Role', backref = 'user', lazy = 'dynamic') - activation_key = db.Column(db.String(86), default = + activation_key = db.Column(db.String(128), default = hashlib.sha512( str(random.getrandbits(256)).encode("utf-8") - ).hexdigest()) + ).hexdigest()[:86]) date_created = db.Column(db.DateTime(), default=datetime.now) last_seen = db.Column(db.DateTime(), default=datetime.now) feeds = db.relationship('Feed', backref = 'subscriber', lazy = 'dynamic', cascade='all,delete-orphan') diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index 712f1da3..9a2b2811 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -912,7 +912,7 @@ def disable_user(user_id=None): else: import random, hashlib - user.activation_key = hashlib.sha512(str(random.getrandbits(256)).encode("utf-8")).hexdigest() + user.activation_key = hashlib.sha512(str(random.getrandbits(256)).encode("utf-8")).hexdigest()[:86] flash(gettext('Account of the user') + ' ' + user.nickname + ' ' + gettext('successfully disabled.'), 'success') db.session.commit() else: -- cgit