ariandanim
Dear all,
I would like to make my SAAS aplication using only single login for every user email, I mean when they try to access using same email in another pc/laptop/mac they unable make it happen, it means like this scenario :
- PC A user A try to login (success)
- PC B user A try to login but make it unable login (they need to login again, but in PC A the user is log off/sign out)
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Aludel - LLM Evaluation Workbench
Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
psantos
Hi
Assuming you are using
mix phx.gen.auth, ausers_tokenstable (Schema) is created. You can change it so that, when a user tries to login, to check this table is there is already a token for him. If yes, you can destroy it.If you are not using
phx.gen.auth, you can just follow the same strategy. Create a table to keep your users sessions, every time a user tries to login, check from this table if an existing session exist for this user.ariandanim
Please elaborate in code Sir
psantos
Not sure what you mean. Which part of it would you like me to write?
For me, its not about the code. Its about the logic. And the logic is there. Persist the user session, when a user tries to login from different device ou web client, delete the previous persisted session.
arcyfelix
There is a guide about it in the official docs:
Kinsua
There is nothing about single login or OTP.
arcyfelix
It is not about a single login, but a login with good practices.
It is a good starting point.
ariandanim
In my country, one account based on email would be disaster for SAAS business, imagine when 1 user email use by 1000 people
Thr3x
When you use mix phx gen auth you get the user_auth.ex file with this function
You can put in another step here as the others have said where you check if there already is an active token for the user and then deny the login.
EDIT: Upon further consideration, I would rather modify the If-statement in the controller
You could modify this part of the code:
Kinsua
And what do you do when they forget their password? You need email anyway to send them their new password or link to reset password. Or you can use an SMS or an external app, but given your problem with sharing emails, I doubt that mobile phone are not shared by many people as well ;D.
But if it’s like an intranet type of thing. For example, students that login with their IDs or some student card ID and some password you/department of the school or library or oganisation give them, why not. But then it would be best to implement it from scratch and forget the whole sending email and reseting thing altogether and the admin of that intranet website would be doing that manually or something when they reach for him or something.
LostKobrakai
Generally I’d advice to drop the existing session and starting a new one rather than not allowing the login if a session exists. That’ll be closer to “a single session active” as the latter might mean no session active, it’s just not known to the server that the existing one is no longer in use.
However this approach cannot prevent account sharing. Users can share cookies like they can share access credentials. It’s just a bit more effort required.