-
Notifications
You must be signed in to change notification settings - Fork 81
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
current_user.is_authenticated returns false in deployment #5
Comments
Hi Max,
Are you sure your code is not triggering the `logout_user()` function anywhere? I’ve never seen this behavior before, so you may want to investigate further your code but feel free to share more details so we can find a solution for that if this is related to the code in this repository. Also I assume you are not using the flask internal server for your solution right? I don’t think this is related but that is something I never tried at a production server.
…________________________________
From: max454545 <notifications@github.com>
Sent: Thursday, June 4, 2020 4:39:18 AM
To: RafaelMiquelino/dash-flask-login <dash-flask-login@noreply.github.com>
Cc: Subscribed <subscribed@noreply.github.com>
Subject: [RafaelMiquelino/dash-flask-login] current_user.is_authenticated returns false in deployment (#5)
Hello,
Thanks for making this repository.
I have been using it with success on a localhost, but as soon as I deploy it, on a hosted server, the user authentication stops behaving. As the user logs in, it registers that the user is authenticated, but within less than a 1s the bool current_user.is_authenticated is set to false.
I have tried everything, and this problem is consistent for my code, that includes the code from this repository, and if one puts this repository on a server and runs it.
Thanks and all the best,
Max H
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub<#5>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AHPKCM7OBVNIY7OGJ7SMNX3RU5FSNANCNFSM4NSLQFQQ>.
|
Hello Rafael, I changed your code by adding the following line to app.py: app = app.server I made the above change in order to use the flask internal server. Is this where I am going wrong? The gif below shows the behavior on a local server (browser on the left), vs the behavior on a hosted server (browser window on the right). In the hosted version, CURRENT USER: TEST disappears because the current_user.is_authenticated is prematurely set to False. |
You shouldn’t need to do that, just run |
I have tried gunicorn on a Heroku server (still with the line 'server = app.server') and the problem persisted. I will try flask run --host=0.0.0.0 and get back to you. Thank you again |
I am truly stuck. Do you know how I could make the passenger_wsgi.py file to correctly run |
I see that dash-auth-flow is also nolonger working in production. Is it possible that Flask login is no longer a viable option for Dash apps? Here is there app, it exhibits the same faulty behavior as dash-flask-login on my server: |
Hey. Please, take a look at these pages: issue133 and https://dash.plotly.com/urls. It looks like your problem not in the login feature but in the multi-page rendering. |
@max454545 , I just made some tests and deployed it to Heroku and it behaves like expected, i.e.: I couldn't reproduce your issue. I added the instructions to run it with gunicorn and deploy to Heroku on the README. If you follow this instructions you'll be able to do that too. |
Actually, I checked it again and it indeed behaves in a strange manner. Maybe there is something to do what @lapshinmr just mentioned. |
So I forced gunicorn to use only one worker when running on Heroku: https://github.com/RafaelMiquelino/dash-flask-login/blob/master/Procfile#L1. |
Another possibility that appears to solve this same issue: #2 |
Thank you @lapshinmr and @RafaelMiquelino for looking into the issue, I appreciate it. lapshinmr you are completely correct it is not the login feature but in the multi-page rendering. github.com/russellromney seems to have encountered the same problem and found a solution: by using |
Hello,
Thanks for making this repository.
I have been using it with success on a localhost, but as soon as I deploy it, on a hosted server, the user authentication stops behaving. As the user logs in, it registers that the user is authenticated, but within less than a 1s the bool current_user.is_authenticated is set to false.
I have tried everything, and this problem is consistent for my code, that includes the code from this repository, and if one puts this repository on a server and runs it.
Thanks and all the best,
Max H
The text was updated successfully, but these errors were encountered: