diff options
author | Michaël Ball <michael.ball@gmail.com> | 2015-12-05 16:46:35 +0000 |
---|---|---|
committer | Michaël Ball <michael.ball@gmail.com> | 2015-12-05 16:46:35 +0000 |
commit | 98a61bb09ccacab827d8b0091bdf8ac6f464dacb (patch) | |
tree | 76a329d775cc9d0589cf8f84e3211f60cc07b3a9 /models | |
parent | 3dc5f811def121a48c17bdb3bb419e5108675e04 (diff) | |
parent | e9749a150cfe8c0548cb78380aba9ab2e4730984 (diff) |
Support token authentication
Diffstat (limited to 'models')
-rw-r--r-- | models/user.py | 10 |
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") |