|
1 | 1 | using System; |
2 | 2 | using System.Collections.Generic; |
| 3 | +using System.Configuration; |
3 | 4 | using System.Data.Entity; |
4 | 5 | using System.Linq; |
5 | 6 | using System.Security.Claims; |
@@ -144,18 +145,29 @@ private async Task SignInAsync(User user, ClaimsIdentity identity = null, bool r |
144 | 145 | } |
145 | 146 |
|
146 | 147 | AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); |
147 | | - // Many browsers do not clean up session cookies when you close them. So the rule of thumb must be: |
148 | | - // For having a consistent behaviour across all browsers, don't rely solely on browser behaviour for proper clean-up |
149 | | - // of session cookies. It is safer to use non-session cookies (IsPersistent == true) in bundle with an expiration date. |
| 148 | + |
| 149 | + // Gp - fix code for NOT using session cookies |
| 150 | + // Don’t rely solely on browser behaviour for proper clean-up of session cookies during a given browsing session. |
| 151 | + // It’s safer to use non-session cookies (IsPersistent == true) with an expiration date for having a |
| 152 | + // consistent behaviour across all browsers and versions. |
150 | 153 | // See http://blog.petersondave.com/cookies/Session-Cookies-in-Chrome-Firefox-and-Sitecore/ |
151 | | - if (rememberMe) { |
152 | | - _authenticationManager.SignIn(new AuthenticationProperties { IsPersistent = true }, identity); |
153 | | - } else { |
154 | | - _authenticationManager.SignIn( |
| 154 | + |
| 155 | + // Gp Commented out: AuthenticationManager.SignIn(new AuthenticationProperties { IsPersistent = rememberMe }, identity); |
| 156 | + if (rememberMe) |
| 157 | + { |
| 158 | + //var rememberBrowserIdentity = AuthenticationManager.CreateTwoFactorRememberBrowserIdentity(user.Id.ToString()); |
| 159 | + AuthenticationManager.SignIn( |
| 160 | + new AuthenticationProperties { IsPersistent = true }, |
| 161 | + identity /*, rememberBrowserIdentity*/); |
| 162 | + } |
| 163 | + else |
| 164 | + { |
| 165 | + AuthenticationManager.SignIn( |
155 | 166 | new AuthenticationProperties |
156 | 167 | { |
157 | 168 | IsPersistent = true, |
158 | | - ExpiresUtc = DateTimeOffset.UtcNow.AddMinutes(int.Parse(System.Configuration.ConfigurationManager.AppSettings["AuthSession.ExpireTimeInMinutes.WhenNotPersistent"] ?? "30")) |
| 169 | + ExpiresUtc = |
| 170 | + DateTimeOffset.UtcNow.AddMinutes(int.Parse(ConfigurationManager.AppSettings["AuthSession.ExpireTimeInMinutes.WhenNotPersistet"] ?? "30")) |
159 | 171 | }, |
160 | 172 | identity); |
161 | 173 | } |
|
0 commit comments