Skip to content

Commit 46e610a

Browse files
committed
fixed problems of #106 and added codes of #107
1 parent 187416c commit 46e610a

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

src/AbpCompanyName.AbpProjectName.WebSpaAngular/App_Start/Startup.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using Abp.Owin;
1+
using System;
2+
using System.Configuration;
3+
using Abp.Owin;
24
using AbpCompanyName.AbpProjectName.Api.Controllers;
35
using AbpCompanyName.AbpProjectName.WebSpaAngular;
46
using Microsoft.AspNet.Identity;

src/AbpCompanyName.AbpProjectName.WebSpaAngular/Controllers/AccountController.cs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Configuration;
34
using System.Data.Entity;
45
using System.Linq;
56
using System.Security.Claims;
@@ -144,18 +145,29 @@ private async Task SignInAsync(User user, ClaimsIdentity identity = null, bool r
144145
}
145146

146147
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.
150153
// 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(
155166
new AuthenticationProperties
156167
{
157168
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"))
159171
},
160172
identity);
161173
}

0 commit comments

Comments
 (0)