This commit is contained in:
Itay Mizeretz 2018-02-25 18:23:52 +02:00
parent 38cf36e165
commit ddc93a67fa
2 changed files with 10 additions and 5 deletions

View File

@ -10,10 +10,10 @@ __author__ = 'itay.mizeretz'
class User(object):
def __init__(self, id, username, password):
def __init__(self, id, username, secret):
self.id = id
self.username = username
self.password = password
self.secret = secret
def __str__(self):
return "User(id='%s')" % self.id
@ -24,9 +24,9 @@ def init_jwt(app):
username_table = {u.username: u for u in users}
userid_table = {u.id: u for u in users}
def authenticate(username, password):
def authenticate(username, secret):
user = username_table.get(username, None)
if user and safe_str_cmp(user.password.encode('utf-8'), password.encode('utf-8')):
if user and safe_str_cmp(user.secret.encode('utf-8'), secret.encode('utf-8')):
return user
def identity(payload):

View File

@ -15,4 +15,9 @@ def load_env_from_file():
return config_json['server_config']
env = ENV_DICT[load_env_from_file()]()
try:
__env_type = load_env_from_file()
env = ENV_DICT[__env_type]()
except Exception:
print('Failed initializing environment: %s' % __env_type)
raise