使用外部提供程序时如何记住MVC5中的登录 [英] How to remember the login in MVC5 when an external provider is used

查看:23
本文介绍了使用外部提供程序时如何记住MVC5中的登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们使用 OWIN 的 MVC5 应用程序中,除了本地帐户之外,我们还使用外部登录 (google).当用户使用本地账号登录时,可以激活记住他的选项,这样他就不用每次都重新登录了.当他使用自己的 Google 帐户登录时,他每次都必须重新点击外部的 google 登录按钮.

In our MVC5-application with OWIN, we use additional to the local accounts also external logins (google). When the user logs in with its local account, he can activate the option to remember him, so he has not to log-in every time newly. When he logs in with his Google-account, he every time must click newly on the external login-button for google.

是否有内置选项可以为外部登录激活记住我"选项?或者有没有安全的方法来添加这个功能?

Is there a built-in option to activate the "remember me"-option also for external logins? Or is there a secure way to add this feature?

推荐答案

当您以用户身份登录时,您只需将 IsPersistent 设置为 true 即可完成此操作(您还需要为也可能是外流)

You just need to set IsPersistent to true to accomplish this when you sign in the user identity (you would want to also add some kind of remember me checkbox for the external flow probably as well)

        AuthenticationManager.SignIn(new AuthenticationProperties { IsPersistent = <rememberMe> }, <userIdentity>);

这篇关于使用外部提供程序时如何记住MVC5中的登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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