Flask-Web-App-Tutorial icon indicating copy to clipboard operation
Flask-Web-App-Tutorial copied to clipboard

in login_user if not force and not user.is_active: AttributeError: 'NoneType' object has no attribute 'is_active'

Open Cug-21 opened this issue 3 years ago • 3 comments

Here is the complete error, i have played around with some of the other tabs on this Github around this issue and have not found success being able to sign up a new user. I have tried to add login_user(user, remember=True) login_user(new_user, remember=True) with no success and tried to delete the database and create a new one, any help is very appreciated.

"ERROR in app: Exception on /sign-up [POST]
Traceback (most recent call last): File "C:\Users\Swag\AppData\Roaming\Python\Python38\site-packages\flask\app.py", line 2525, in wsgi_app response = self.full_dispatch_request() File "C:\Users\Swag\AppData\Roaming\Python\Python38\site-packages\flask\app.py", line 1822, in full_dispatch_request rv = self.handle_user_exception(e) File "C:\Users\Swag\AppData\Roaming\Python\Python38\site-packages\flask\app.py", line 1820, in full_dispatch_request rv = self.dispatch_request()
File "C:\Users\Swag\AppData\Roaming\Python\Python38\site-packages\flask\app.py", line 1796, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) File "c:\Users\Swag\OneDrive - Bentley University\Personal\Flask Web App Tutorial\website\auth.py", line 59, in sign_up login_user(user, remember=True) File "C:\Users\Swag\AppData\Roaming\Python\Python38\site-packages\flask_login\utils.py", line 180, in login_user if not force and not user.is_active: AttributeError: 'NoneType' object has no attribute 'is_active'
141.133.213.232 - - [31/Oct/2022 15:12:33] "POST /sign-up HTTP/1.1" 500 -

Let me know if you need to see any of my code.

Cug-21 avatar Oct 31 '22 19:10 Cug-21

I fixed it, should have just delted the first login user and keep the one with login user (new user)

Cug-21 avatar Nov 01 '22 00:11 Cug-21

Hey, I have gotten the same error, and by your comment I didn't really understand what I should do to solve this issue, if you are able to, could you briefly just explain how you fixed the issue?

gitbrocode avatar Dec 26 '22 05:12 gitbrocode

In sign up, change:

login_user(user, remember=True)

to:

login_user(new_user, remember=True)

and that should solve it

DuXonium avatar Jan 30 '23 00:01 DuXonium