Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16750

How to allow one device login in react-native?

$
0
0

I have implemented an APP that should allow one device one account which I will pass the uniqueId to Web API to be save alongside with user account row in SQL database. This validation happen on Splash and Authentication screen. The flow as below:

Logic Flow:

Device 1:

  1. Splash screen: retrieve value from AsyncStorage. If none, proceed to Authentication. If have value, go to #3
  2. Fill username and password and click Login.
  3. APP will fetch with web API together with userName, encrypted password and uniqueId retrieved from DeviceInfo module.
  4. If uniqueId column in SQL is empty, update the column. If have value, compare with uniqueId param. Condition: MATCH-return OK, NOT MATCH-return multiple login alert as exception.
  5. Fetch promise resolve OK:- Save encrypted userId and userName into AsyncStorage and go to Dashboard
  6. Fetch promise reject:- Show alert and stay at current screen.
  7. Notify Web API to clear the uniqueId column and AsyncStorage will clear the token value when user click Logout button

Device 2:

  1. Follow directly as Device 1

Situation:

User register 1 device or 1 account. So, if user have 2 device, they have to logout device 1 and login on device 2 to prevent the "Multiple Device Login" alert.

Problem:

As user reported Device 2 are lost or stolen. Our admin system will clear the uniqueId column for reported login information. But the real deal is(for Android, not familiar with ios yet); If user is not logout and press HOME button which fake the report, the APP will rest at task manager and use Device 1 to login. So at the end, 2 device can use 1 account.

Inquiry for the best solutions for the faced PROBLEM:

  1. Do I need to pass the uniqueId everytime the APP will fetch from the Web API to be validated when I will enquiry Web API for data?
  2. Is it practical to use Headless JS to check with Web API and inform the UI that multiple device alert and automatically logout the current device?
  3. Any other better ideas?

Most of tutorial or example show the validation as I doing now, but not found yet for situation on my problem.


Viewing all articles
Browse latest Browse all 16750

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>