Closed max454545 closed 4 years ago
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 GitHubhttps://github.com/RafaelMiquelino/dash-flask-login/issues/5, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AHPKCM7OBVNIY7OGJ7SMNX3RU5FSNANCNFSM4NSLQFQQ.
Hello Rafael, Thanks for getting back so quickly.
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.
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?
You shouldn’t need to do that, just run flask run --host=0.0.0.0
and your app you’ll be served externally. However I recommended you use gunicorn, the Flask internal server is not suitable for production environment. Take a look here for an example on how to serve the app with gunicorn: https://github.com/RafaelMiquelino/flask-text-reader/blob/master/README.md#instructions.
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.
Our preferred host uses passenger as the application server. The only way that I can think of making the passenger_wsgi.py file is by adding the line 'server = app.server' to app.y, which is the incorrect way to do it.
Do you know how I could make the passenger_wsgi.py file to correctly run dash-flask-login, without altering app.py?
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: http://dash-auth-flow.herokuapp.com/login
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. I have a working example on the link https://dash-flask-login-rm.herokuapp.com that you can check by yourself. You'll probably need to investigate deeper your code and please share here when you managed to solve it.
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. It is working now but it is more a workaround than a solution. It seems the issue is really related to the mentioned above by @lapshinmr. The Dash maintainer says it is solved from the version 0.11.0 but we are using the version 1.4.1 here and the issue is still there, so it needs to be further investigated. @max454545, you should probably work on a more robust solution for your case and if you find, please share it here. For the moment I'm closing this issue as this is not related to the login process but to the multi-page rendering process.
Another possibility that appears to solve this same issue: https://github.com/RafaelMiquelino/dash-flask-login/issues/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: https://github.com/russellromney/dash-auth-flow/issues/2
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