'How do you handle authorization in react native?
Hello AWESOME DEVELOPER all over the world!
I'm currently developing mobile application with React Native.
I have three kind of screen.
- Screen where every user stay
- Screen where only user logged-in stay
- Screen where only user who has payed stay
I think this is a standard application where user can pay
Here's the question.
How do you guys handle authentication and authorization?
If user wants to enter screen for only payed user, How do you guys check if the user has payed or not?
First Method,
In useEffect, when you call api, if user hasn't payed yet, server would return error. Then you let user go back to previous screen.
With this method, it's good to check user at every screen but user could get a glimpse of payed screen when getting data. I think this is a bad user experience.
Second Method,
There's a button navigating to payed screen.
When you press this button, in onPress event, you could check if the user has payed or not.
With this method, user experience would be better than first option. but button is heavier than before.
What's your opinion?
Feel free to share your knowledge!
Solution 1:[1]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tarik |
