-
Notifications
You must be signed in to change notification settings - Fork 17.4k
fix: Make g.user attribute access safe for public users #14287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1024,7 +1024,7 @@ def estimate_query_cost( | |
| if not cls.get_allow_cost_estimate(extra): | ||
| raise Exception("Database does not support cost estimation") | ||
|
|
||
| user_name = g.user.username if g.user else None | ||
| user_name = g.user.username if g.user and hasattr(g.user, "username") else None | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it probably makes more sense to just check if the user is authenticated, using
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I originally was checking
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok |
||
| parsed_query = sql_parse.ParsedQuery(sql) | ||
| statements = parsed_query.get_statements() | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for reference: https://github.com/maxcountryman/flask-login/blob/89ce0167a8603d2c53fa2d0d604a20bfe03c0eaf/flask_login/mixins.py#L75