简体   繁体   English

iOS开发查看用户是否已登录以及其他用户登录问题

[英]iOS Development see if user is logged in and other user log in questions

I am working on my first app so I am not so experienced with this stuff yet. 我正在开发我的第一个应用程序,所以我对这些东西还不那么熟悉。 I have figured out how to send a POST request url to a php page and process the php to register a new user in the mySQL database or log in to the app by connecting to the database to see if the user exists. 我已经弄清楚了如何将POST请求url发送到php页面并处理php以在mySQL数据库中注册新用户,或者通过连接到数据库以查看该用户是否存在来登录应用程序。

First off, does that seem correct? 首先,这看起来是否正确? To just send the request to register a user with text field variables and to log in by checking if the text field information exists in the database or should I be implementing some other ways to do this? 只是发送请求以使用文本字段变量注册用户并通过检查数据库中是否存在文本字段信息来登录,还是我应该采用其他方法来做到这一点?

Second, What should I be doing once the user enters in his credentials in order to tell the app that the user is logged in so that if the app closes down and the user goes back to the app, it will automatically log the user back in. 其次,一旦用户输入凭据以告知应用程序该用户已登录,我应该怎么做,以便如果该应用程序关闭并且用户返回到该应用程序,它将自动将用户重新登录。

That being said, the way this app is going to work (as of now) is the user will log into the app, and the log in view will go to a different view but then the user can log out and it will go back to the log in view. 话虽这么说,该应用程序的运行方式(截至目前)是用户将登录到该应用程序,并且登录视图将转到另一个视图,但随后用户可以注销并返回到登录视图。 Once I can tell the app that the user is logged in, I should be able to tell the app that the user isn't logged in anymore. 一旦我告诉应用程序该用户已登录,就应该能够告诉该应用程序该用户不再登录。

How you implement your database security is up to you. 如何实现数据库安全性取决于您。 I would recommend you route your authorization/updates/gets/posts to an API so you don't need a PHP "middle man" (unless the PHP is your API) and you can send requests directly to the API layer and handle the rest on the server. 我建议您将授权/更新/获取/发布路由到API,这样就不需要PHP“中间人”(除非PHP是您的API),并且您可以将请求直接发送到API层并处理其余部分在服务器上。

As for the plain text part, it is a common security practice to encrypt passwords on the database. 对于纯文本部分,加密数据库上的密码是一种常见的安全做法。 On the client side, I'd suggest using the Apple Keychain to store the username/password for future use. 在客户端,我建议使用Apple钥匙串存储用户名/密码,以备将来使用。 In iOS, this can be easily implemented using this Keychain Wrapper if you're using ARC or this one if you aren't. 在iOS中,这可以很容易地使用实现这个钥匙扣包装 ,如果你正在使用ARC或这一个 ,如果你不是。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM