0

I'm developing an mobile application, people login with accounts that stored in sql. I gave a new guid for each login, that guid stored in sql and mobile device. But in this scenario user can login another mobile device cuz i check guid from device. There is something wrong but i can't figure it out. User can login with 2 mobile device and we dont want that.

Preferences.Get("myCurrentUserID", "");

I save userID guid from that sample code. Than compare it another guid that come from service and if they are the same no problem for us but if they are not same; it means there is another device logged in.

Would you please give me an idea how to fix this problem?

ToolmakerSteve
  • 18,547
  • 14
  • 94
  • 196
  • 2
    "if they are not same; it means there is another device logged in." - then when you detect this condition prevent them from logging in – Jason Jun 09 '23 at 11:52
  • I can catch this but user connect from other device, than i can not catch from main device cuz i store userID on device. Im a bit confused and lost. I just can't fix this. – Mert Altiparmak Jun 09 '23 at 12:41
  • 1
    if they login from a 2nd device do you want them to be forced to logout of the first device? – Jason Jun 09 '23 at 13:13
  • 1
    Yes, i want to force to log out from first device. Exactly! – Mert Altiparmak Jun 09 '23 at 13:33
  • 2
    then you need to implement some sort of mechanism to force updates to clients, like SignalR. Or you can perform the check periodically with a timer, or do it every time the app requests data from the server – Jason Jun 09 '23 at 13:34
  • When user navigate to other page i can control userID, is that logical ? – Mert Altiparmak Jun 09 '23 at 13:39
  • 1
    You can check this [How to prevent a user from logging into multiple devices and how do I end the session from the previous device?](https://stackoverflow.com/questions/65117958/how-to-prevent-a-user-from-logging-into-multiple-devices-and-how-do-i-end-the-se) the answer provides two different methods to achieve this. – Guangyu Bai - MSFT Jun 12 '23 at 06:38

0 Answers0