Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remember the login in MVC5 when an external provider is used

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?

like image 221
HCL Avatar asked Apr 20 '14 10:04

HCL


People also ask

How do I log into MVC identity with email instead of UserName?

cs change the property Email to UserName , remove the [EmailAddress] annotation from there and change the [Display(Name = "Email")] to [Display(Name = "Login")] or something you want to display. If you want to keep Email property, then add UserName property to the same view model and make it as required.


1 Answers

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>);
like image 172
Hao Kung Avatar answered Sep 30 '22 07:09

Hao Kung