-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release/2.1] Fix site handing after enabling user time zone feature (#…
…17077) --------- Co-authored-by: Hisham Bin Ateya <[email protected]> Co-authored-by: Mike Alhayek <[email protected]>
- Loading branch information
1 parent
adb5ce9
commit 227dd83
Showing
4 changed files
with
44 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/OrchardCore.Modules/OrchardCore.Users/TimeZone/Handlers/UserEventHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Microsoft.Extensions.Caching.Distributed; | ||
using OrchardCore.Users.Handlers; | ||
|
||
namespace OrchardCore.Users.TimeZone.Handlers; | ||
|
||
public class UserEventHandler : UserEventHandlerBase | ||
{ | ||
private const string CacheKey = "UserTimeZone/"; | ||
|
||
private readonly IDistributedCache _distributedCache; | ||
|
||
public UserEventHandler(IDistributedCache distributedCache) | ||
{ | ||
_distributedCache = distributedCache; | ||
} | ||
|
||
public override Task DeletedAsync(UserDeleteContext context) | ||
=> ForgetCacheAsync(context.User.UserName); | ||
|
||
public override Task UpdatedAsync(UserUpdateContext context) | ||
=> ForgetCacheAsync(context.User.UserName); | ||
|
||
public override Task DisabledAsync(UserContext context) | ||
=> ForgetCacheAsync(context.User.UserName); | ||
|
||
private Task ForgetCacheAsync(string userName) | ||
{ | ||
var key = GetCacheKey(userName); | ||
|
||
return _distributedCache.RemoveAsync(key); | ||
} | ||
|
||
internal static string GetCacheKey(string userName) | ||
=> CacheKey + userName; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters