user.is_authenticated AttributeError: can't set attribute
See original GitHub issueIn the sample code:
@login_manager.request_loader
def request_loader(request):
email = request.form.get('email')
if email not in users:
return
user = User()
user.id = email
# DO NOT ever store passwords in plaintext and always compare password
# hashes using constant-time comparison!
user.is_authenticated = request.form['pw'] == users[email]['pw']
return user
When username is correct and password is incorrect, get follow error message:
user.is_authenticated = request.form['pw'] == users[email]['pw']
AttributeError: can't set attribute
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:9
Top Results From Across the Web
Django login - getting an AttributeError can't set attribute
Django login - getting an AttributeError can't set attribute ... if the existing session corresponds to a different 68 # authenticated user.
Read more >[Solved] AttributeError: can't set attribute in python - Finxter
Fix #1: Use the namedtuple. The easiest way to fix the AttributeError:can't set attribute is to create a new namedtuple object with the...
Read more >Request object does not allow attributes to be set
... I get an 'AttributeError: can't set attribute' when attempting to set the user attribute on the request object: request.session[SESSION_KEY] = user.id
Read more >django.contrib.auth
This is a way to tell if the user has been authenticated. This does not imply any permissions and doesn't check if the...
Read more >Customizing authentication in Django
Once a user has authenticated, Django stores which backend was used to ... This change can't be done automatically and requires manually fixing...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
All users that aren’t anonymous are authenticated, it’s not a property you need to set. Instead, if the passwords don’t match, just don’t return a user object at all.
Someone needs to fix that documentation. This is not correct: user.is_authenticated = request.form[‘pw’] == users[email][‘pw’]