Skip to content

Type of g.flask_httpauth_user  #130

@tabebqena

Description

@tabebqena

After successful authentication, What is the type of g.flask_httpauth_user that is added by the @login_required decorator?

I expect to find user object, But As I can understand from the source code, It is always str or None. In the case of string it will be the username.
If my note is true, It will is better to change this behavior to store user object. If this will break the backword compatibility, I suggest to add optional user loader callback, that will be called after successful login.

The current behavior break the example mentioned :

`@bp.route('/tokens', methods=['POST'])
 @basic_auth.login_required
def get_token():
    token = basic_auth.current_user().get_token()
    db.session.commit()
    return jsonify({'token': token})` 

basic_auth.current_user() return the g.flask_httpauth_user which has no method named get_token()

Thank you.

Version: 4.4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions