Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Feb 15, 2019
2 parents c717d71 + bb9809a commit 4e14d92
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions tests/integration/it_auth_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_incorrect_username(db_session):
"""Do not remove db_session dependency. It is injected
in order to trigger db migration.
"""
assert (login("unknown", "unknown") == "Incorrect username.")
assert (login("unknown", "unknown") == "login.failed")


def test_incorrect_password(db_session):
Expand All @@ -24,7 +24,7 @@ def test_incorrect_password(db_session):
db_session.add(employee)
db_session.commit()
error = login("vgv", "unknown")
assert (error == "Incorrect password.")
assert (error == "login.failed")


def test_login(db_session):
Expand Down
15 changes: 7 additions & 8 deletions timeless/auth/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@

def login(username="", password=""):
"""Login user
@todo #59:30min The backend should return only error codes for login procedure,
not hardcoded messages. The codes should then be translated into (mapped to)
Strings on the UI, so we can easily have internationalization or change
error messages without having to rebuild + redeploy the backend.
@todo #201:30min Translate login error codes.
The codes returned from login errors should then be translated into (
mapped to) Strings on the UI, so we can easily have
internationalization or change error messages without having to
rebuild + redeploy the backend.
"""
user = Employee.query.filter_by(username=username).first()
error = None
if user is None:
error = "Incorrect username."
elif not user.validate_password(password):
error = "Incorrect password."
if user is None or not user.validate_password(password):
error = "login.failed"
if error is None:
session.clear()
session["user_id"] = user.id
Expand Down

2 comments on commit 4e14d92

@0pdd
Copy link

@0pdd 0pdd commented on 4e14d92 Feb 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 59-2d69b226 disappeared from timeless/auth/auth.py, that's why I closed #201. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

@0pdd
Copy link

@0pdd 0pdd commented on 4e14d92 Feb 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 201-b5198280 discovered in timeless/auth/auth.py and submitted as #269. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

Please sign in to comment.