简体   繁体   English

Android Auth0锁定清除缓存

[英]Android Auth0 Lock Clear Cache

I'm integrating Auth0's Lock as part of the login process of my app, as to adhere with the web implementation of Auth0's login. 我将Auth0的Lock集成到我的应用程序的登录过程中,以符合Auth0的登录的网络实现。

I followed the directions in the README.md of the Lock (Android) repository and I'm able to login with Google without issues. 我按照Lock(Android)存储库的README.md中的README.md ,因此可以无问题地使用Google登录。

The problem I'm facing is that I'm unable to indicate to Auth0 or the Lock that I have logged my user out, so I'm never again prompted to choose which account I want to login as when I re-login. 我面临的问题是我无法向Auth0或Lock指示已注销用户,因此当我重新登录时,再也不会提示我选择要登录的帐户。 I currently store my session info in SharedPreferences and my current logout procedure is to clear that data. 我目前将会话信息存储在SharedPreferences而当前的注销过程是清除该数据。 I am able to navigate back to the UI of the login screen, but as soon as I touch on the Google icon to login via Google, Auth0 authenticates against my previously logged in user without prompting me to enter my credentials. 我可以导航回登录屏幕的用户界面,但是只要我触摸Google图标以通过Google登录,Auth0就会根据我之前登录的用户进行身份验证,而不会提示我输入我的凭据。

Is there an official way to clear the cache with Auth0's Lock? 是否有使用Auth0的锁清除缓存的官方方法?

I would recommend you to follow the Android Quickstart guide, more specifically, the part about session handling where it describes one possible way of maintaining a user session after login. 我建议您遵循Android快速入门指南,更具体地说,是有关会话处理的部分,该部分描述了登录后维护用户会话的一种可能方式。

The last section of the session handling part is about how to achieve log out. 会话处理部分的最后一部分是关于如何实现注销的。 The provided sample code is the following: 提供的示例代码如下:

private void logout() {
  // Clear credentials (depends on how you store them in the first place)
  setUserCredentials(null);

  // Navigate to Lock login screen
  startActivity(new Intent(this, LoginActivity.class));
}

Have in mind that the setUserCredentials is specific to that particular sample, the general idea would be that you store the received tokens somewhere and then provide the user the option to log out, which triggers the cleanup of the tokens and the redirection to the login screen. 请记住, setUserCredentials特定于该特定样本,通常的想法是,将收到的令牌存储在某个地方,然后为用户提供注销选项,这将触发令牌的清理以及重定向到登录屏幕。

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

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