Authenticate a username and password against our database :param username: :param password: :return: authenticated username
(username, password)
| 38 | |
| 39 | @hug.cli() |
| 40 | def authenticate_user(username, password): |
| 41 | """ |
| 42 | Authenticate a username and password against our database |
| 43 | :param username: |
| 44 | :param password: |
| 45 | :return: authenticated username |
| 46 | """ |
| 47 | user_model = Query() |
| 48 | user = db.get(user_model.username == username) |
| 49 | |
| 50 | if not user: |
| 51 | logger.warning("User %s not found", username) |
| 52 | return False |
| 53 | |
| 54 | if user["password"] == hash_password(password, user.get("salt")): |
| 55 | return user["username"] |
| 56 | |
| 57 | return False |
| 58 | |
| 59 | |
| 60 | @hug.cli() |
nothing calls this directly
no test coverage detected