Disable concurrent logins for Basic Auth

Hello, I would like to only allow on simultaneous user per login for my dashboard. I am using the BasicAuth functionality in the dash_auth library. Can I achieve this using BasicAuth or will I need to switch to another method?

Hello @warrenon,

Welcome to the community!

I dont use the BasicAuth method, I use Flask-Login. With Flask-Login, your user has a session cookie that is tied with their username after logging in.

What you can do is then store the session info along with the username in a database, and then check to make sure that their session is the last active one with their requests. When they log in, you can either have them force the other one off automatically, or prompt them to confirm.

Here is a link to a flow using Flask Login:

For this, you will need to be using Dash Pages, which isnt difficult to implement.

1 Like

Nice, I’ll try to implement that. I’m hosting on Heroku so I was also considering using one of their add-ons to manage the login. You heard of anyone using that solution?

Nope… but, if you want to eventually cater dynamic content to specific users, you’ll need to make sure there is some way to access the user that is logged in.

1 Like