forked from p15670423/monkey
island: Give _authenticate() more descriptive name and remove comment
This commit is contained in:
parent
39c274c4d9
commit
a8646fc056
|
@ -38,10 +38,9 @@ class Authenticate(flask_restful.Resource):
|
||||||
"password": "my_password"
|
"password": "my_password"
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
(username, password) = Authenticate._get_credentials_from_request(request)
|
(username, password) = Authenticate._get_credentials_from_request(request)
|
||||||
# If the user and password have been previously registered
|
|
||||||
if self._authenticate(username, password):
|
if self._credentials_match_registered_user(username, password):
|
||||||
access_token = flask_jwt_extended.create_access_token(
|
access_token = flask_jwt_extended.create_access_token(
|
||||||
identity=user_store.UserStore.username_table[username].id
|
identity=user_store.UserStore.username_table[username].id
|
||||||
)
|
)
|
||||||
|
@ -62,7 +61,7 @@ class Authenticate(flask_restful.Resource):
|
||||||
return (username, password)
|
return (username, password)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _authenticate(username, password):
|
def _credentials_match_registered_user(username, password):
|
||||||
user = user_store.UserStore.username_table.get(username, None)
|
user = user_store.UserStore.username_table.get(username, None)
|
||||||
if user and bcrypt.checkpw(password.encode("utf-8"), user.secret.encode("utf-8")):
|
if user and bcrypt.checkpw(password.encode("utf-8"), user.secret.encode("utf-8")):
|
||||||
return True
|
return True
|
||||||
|
|
Loading…
Reference in New Issue