mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Fixing possible stackoverflow in FormsAuthenticationService
--HG-- branch : 1.x
This commit is contained in:
@@ -12,6 +12,7 @@ namespace Orchard.Security.Providers {
|
||||
private readonly IContentManager _contentManager;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private IUser _signedInUser;
|
||||
private bool _isAuthenticated = false;
|
||||
|
||||
public FormsAuthenticationService(IClock clock, IContentManager contentManager, IHttpContextAccessor httpContextAccessor) {
|
||||
_clock = clock;
|
||||
@@ -56,20 +57,24 @@ namespace Orchard.Security.Providers {
|
||||
|
||||
var httpContext = _httpContextAccessor.Current();
|
||||
httpContext.Response.Cookies.Add(cookie);
|
||||
|
||||
_isAuthenticated = true;
|
||||
_signedInUser = user;
|
||||
}
|
||||
|
||||
public void SignOut() {
|
||||
_signedInUser = null;
|
||||
_isAuthenticated = false;
|
||||
FormsAuthentication.SignOut();
|
||||
}
|
||||
|
||||
public void SetAuthenticatedUserForRequest(IUser user) {
|
||||
_signedInUser = user;
|
||||
_isAuthenticated = true;
|
||||
}
|
||||
|
||||
public IUser GetAuthenticatedUser() {
|
||||
if (_signedInUser != null)
|
||||
if (_signedInUser != null || _isAuthenticated)
|
||||
return _signedInUser;
|
||||
|
||||
var httpContext = _httpContextAccessor.Current();
|
||||
@@ -84,6 +89,8 @@ namespace Orchard.Security.Providers {
|
||||
Logger.Fatal("User id not a parsable integer");
|
||||
return null;
|
||||
}
|
||||
|
||||
_isAuthenticated = true;
|
||||
return _signedInUser = _contentManager.Get(userId).As<IUser>();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user