javascript - How would user login authentication work with React native? - Stack Overflow

What would be the safest and the best approach to allowing a user to login to an app using their login

What would be the safest and the best approach to allowing a user to login to an app using their login details from a web server on a React native app. I assume using Fetch to POST data to a server would be the only way to transmit the data. Is there any encryption that ships with React native or Fetch? and would it be best to use a token based system so the server would pass back a token which React Native would then store as a global prop which could be called upon subsequent data requests to check if the user is still logged in? Also how would login stay persistent if the user left the app? Thanks for any responses in advance!

What would be the safest and the best approach to allowing a user to login to an app using their login details from a web server on a React native app. I assume using Fetch to POST data to a server would be the only way to transmit the data. Is there any encryption that ships with React native or Fetch? and would it be best to use a token based system so the server would pass back a token which React Native would then store as a global prop which could be called upon subsequent data requests to check if the user is still logged in? Also how would login stay persistent if the user left the app? Thanks for any responses in advance!

Share Improve this question asked Oct 4, 2015 at 14:32 Jonathan LockleyJonathan Lockley 1,3505 gold badges18 silver badges28 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

Like Ryan mentioned the fetch api will work over SSL. I think a token based approach is the most flexible because you can then persist the login status within the app by storing the token on the device using react natives AsyncStorage api. If you need to municate with your web app through a webview you can pass the token and authorize the request as needed.

The AsyncStorage api is based on the browsers localStorage api except it's wrapped in a promise.

The safest would be over SSL. You can certainly use SSL with a fetch() call. As for logging in, I implemented a React Native Login example that uses a WebView to login to your existing backend. Check this out and see if it solves your issue: https://github./ryanmcdermott/react-native-login

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745381003a4625225.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信