aboutsummaryrefslogtreecommitdiff
path: root/src/web/lib/user_utils.py
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2016-02-18 08:59:13 +0100
committerCédric Bonhomme <cedric@cedricbonhomme.org>2016-02-18 08:59:13 +0100
commit2e5a241777ef0bb0d76420d39bf3be41e16e042a (patch)
tree3223b8fba4fa244fa97b0df0b8bf8c5b91aeffec /src/web/lib/user_utils.py
parentCheck if the id of the category is '0'. (diff)
downloadnewspipe-2e5a241777ef0bb0d76420d39bf3be41e16e042a.tar.gz
newspipe-2e5a241777ef0bb0d76420d39bf3be41e16e042a.tar.bz2
newspipe-2e5a241777ef0bb0d76420d39bf3be41e16e042a.zip
New management of the token for the account confirmation.
Diffstat (limited to 'src/web/lib/user_utils.py')
-rw-r--r--src/web/lib/user_utils.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/web/lib/user_utils.py b/src/web/lib/user_utils.py
new file mode 100644
index 00000000..78468379
--- /dev/null
+++ b/src/web/lib/user_utils.py
@@ -0,0 +1,23 @@
+
+
+from itsdangerous import URLSafeTimedSerializer
+
+from bootstrap import application
+
+
+def generate_confirmation_token(email):
+ serializer = URLSafeTimedSerializer(app.config['SECRET_KEY'])
+ return serializer.dumps(email, salt=app.config['SECURITY_PASSWORD_SALT'])
+
+
+def confirm_token(token, expiration=3600):
+ serializer = URLSafeTimedSerializer(app.config['SECRET_KEY'])
+ try:
+ email = serializer.loads(
+ token,
+ salt=app.config['SECURITY_PASSWORD_SALT'],
+ max_age=expiration
+ )
+ except:
+ return False
+ return email
bgstack15