MCPcopy Index your code
hub / github.com/hugapi/hug / authenticate_user

Function authenticate_user

examples/secure_auth_with_db_example.py:40–57  ·  view source on GitHub ↗

Authenticate a username and password against our database :param username: :param password: :return: authenticated username

(username, password)

Source from the content-addressed store, hash-verified

38
39@hug.cli()
40def 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()

Callers

nothing calls this directly

Calls 2

hash_passwordFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected