Browse Source

Address pycodestyle complaints

merge-requests/1/head
Drew Short 6 years ago
parent
commit
207c72fe54
  1. 2
      server/atheneum/__init__.py
  2. 13
      server/atheneum/service/user_service.py
  3. 4
      server/atheneum/service/user_token_service.py

2
server/atheneum/__init__.py

@ -36,7 +36,7 @@ def create_app(test_config=None):
app.config.from_mapping( app.config.from_mapping(
SECRET_KEY='dev', SECRET_KEY='dev',
SQLALCHEMY_DATABASE_URI='sqlite:///{}/atheneum.db' SQLALCHEMY_DATABASE_URI='sqlite:///{}/atheneum.db'
.format(data_directory),
.format(data_directory),
SQLALCHEMY_TRACK_MODIFICATIONS=False SQLALCHEMY_TRACK_MODIFICATIONS=False
) )

13
server/atheneum/service/user_service.py

@ -7,14 +7,13 @@ from atheneum.service import authentication_service
def register(name: str, password: str, role: str) -> User: def register(name: str, password: str, role: str) -> User:
password_hash, password_revision = authentication_service.get_password_hash(
password)
pw_hash, pw_revision = authentication_service.get_password_hash(password)
new_user = User( new_user = User(
name=name, name=name,
role=role, role=role,
password_hash=password_hash,
password_revision=password_revision,
password_hash=pw_hash,
password_revision=pw_revision,
creation_time=datetime.now(), creation_time=datetime.now(),
version=0) version=0)
db.session.add(new_user) db.session.add(new_user)
@ -38,10 +37,10 @@ def update_last_login_time(user: User):
def update_password(user: User, password: str): def update_password(user: User, password: str):
password_hash, password_revision = authentication_service.get_password_hash(
pw_hash, pw_revision = authentication_service.get_password_hash(
password) password)
user.password_hash = password_hash
user.password_revision = password_revision
user.password_hash = pw_hash
user.password_revision = pw_revision
db.session.commit() db.session.commit()

4
server/atheneum/service/user_token_service.py

@ -15,7 +15,8 @@ def create(
Create and save a UserToken Create and save a UserToken
:param user: The User object to bind the token to :param user: The User object to bind the token to
:param note: An optional field to store additional information about a token
:param note: An optional field to store additional information about a
token
:param enabled: A boolean to indicate whether a token can be considered :param enabled: A boolean to indicate whether a token can be considered
eligible for authentication eligible for authentication
:param expiration_time: An optional argument to determine when the token :param expiration_time: An optional argument to determine when the token
@ -49,4 +50,3 @@ def delete(user_token: UserToken) -> bool:
def find_by_user_and_token(user: User, token: str) -> Optional[UserToken]: def find_by_user_and_token(user: User, token: str) -> Optional[UserToken]:
return UserToken.query.filter_by(user_id=user.id, token=token).first() return UserToken.query.filter_by(user_id=user.id, token=token).first()
Loading…
Cancel
Save