inventorymgr/auth.py
def login() -> Any:
    """Flask view for logging a user in."""
    user_obj = api.LoginRequest.parse_obj(request.json)
    username = user_obj.username
    password = user_obj.password

    if is_password_correct(username, password):
        user = fetch_user(username)
        session["user_id"] = user["id"]
        response = make_response(user)
        response.set_cookie("is_authenticated", "1")
        return response

    raise APIError(reason="invalid_user_or_password", status_code=403)
Flask view for logging a user in.
Flask view for logging a user in.
Flask view for logging a user in .
def login() -> Any:
    user_obj = api.LoginRequest.parse_obj(request.json)
    username = user_obj.username
    password = user_obj.password
    if is_password_correct(username, password):
        user = fetch_user(username)
        session["user_id"] = user["id"]
        response = make_response(user)
        response.set_cookie("is_authenticated", "1")
        return response
    raise APIError(reason="invalid_user_or_password", status_code=403)
def login ( ) -> Any : user_obj = api . LoginRequest . parse_obj ( request . json ) username = user_obj . username password = user_obj . password if is_password_correct ( username , password ) : user = fetch_user ( username ) session [ "user_id" ] = user [ "id" ] response = make_response ( user ) response . set_cookie ( "is_authenticated" , "1" ) return response raise APIError ( reason = "invalid_user_or_password" , status_code = 403 )
Flask view for logging a user in.
Flask view for logging a user in .
"""Flask view for logging a user in."""