summaryrefslogtreecommitdiff
path: root/models
diff options
context:
space:
mode:
authorMichaël Ball <michael.ball@gmail.com>2015-12-05 12:26:19 +0000
committerMichaël Ball <michael.ball@gmail.com>2015-12-05 16:45:34 +0000
commite9749a150cfe8c0548cb78380aba9ab2e4730984 (patch)
tree76a329d775cc9d0589cf8f84e3211f60cc07b3a9 /models
parent3dc5f811def121a48c17bdb3bb419e5108675e04 (diff)
Support api key authentication
Diffstat (limited to 'models')
-rw-r--r--models/user.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/models/user.py b/models/user.py
index f912e43..925df5e 100644
--- a/models/user.py
+++ b/models/user.py
@@ -1,4 +1,8 @@
-from common.security import pwd_context
+import os
+
+from flask.ext.login import make_secure_token
+
+from common.security import pwd_context, secret_key
class User:
@@ -46,7 +50,9 @@ class User:
else:
hash = pwd_context.encrypt(password)
- return hash
+ api_key = make_secure_token(hash, os.urandom(64), key=secret_key)
+
+ return hash, api_key
else:
raise ValueError("No user")