iOS:登录后如何验证用户(自动登录)? [英] iOS: How to authenticate a user after login (for auto login)?

查看:138
本文介绍了iOS:登录后如何验证用户(自动登录)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用自动登录功能。因此,当用户打开应用程序时,他将被委派给登录屏幕。当他成功登录时,他应该被引导到他的帐户。我称之为帐户屏幕。现在,当用户重新启动应用程序时,他应该直接转到他的帐户,而不会看到登录屏幕。

I'd like to use an auto-login function. So when the user opens the app, he gets delegated to a "login screen". When he logged in successfully he should be directed to his account. I call this the "account screen". Now when the user restarts the app, he should directly get directed to his account, without seeing the "login screen".

登录功能在我的项目中已经正常工作(用户名和密码保存在UserDefault中,但每次关闭应用程序时,我都必须再次登录。所以我的问题是:如何自动登录用户?或者更好地说:我如何检查数据(保存在UserDefault中)是否与数据库中的数据(MYSQL)相同?

The login function already works fine in my project (username and password are saved in UserDefault), but every time I close the app, I have to login again. So my question is: How do auto login the user? Or better said: How do I check if the data (saved in UserDefault) is the same as in the database (MYSQL)?

推荐答案

<要回答这个问题:如果要使用钥匙串数据自动登录,请使用免费框架SFHFKeychainUtils。它在keychain中保存用户名,密码和服务名称。如果你想要检索它,只需在NSUserDefaults中保存用户名,你就可以轻松获得密码。

To answer the question: if you want to auto-login with keychain data, use the free framework "SFHFKeychainUtils". It saves username, password and servicename in keychain. if you want to retrieve it, just save the username in NSUserDefaults and you can get the password with ease.

我们走了:

SiFi HiFi框架 https ://github.com/ldandersen/scifihifi-iphone/tree/master/security

SiFi高保真框架(ARC兼容): https://stackoverflow.com/a/10348964/1011125

如何使用SFHFKeychainUtils: http://gorgando.com/blog/technology/iphone_development/simple-iphone-tutorial-password-management-using-the-keychain-by-using-sfhfkeychainutils

这篇关于iOS:登录后如何验证用户(自动登录)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆