Skip to content

Commit

Permalink
fix the user roles cache issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
zyhfish committed Feb 21, 2024
1 parent 6b4ddec commit ae9ca40
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions DNN Platform/Library/Entities/Users/UserInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ namespace DotNetNuke.Entities.Users
public class UserInfo : BaseEntityInfo, IPropertyAccess, IUserInfo
{
private readonly ConcurrentDictionary<int, UserSocial> social = new ConcurrentDictionary<int, UserSocial>();
private readonly ConcurrentDictionary<int, string[]> roles = new ConcurrentDictionary<int, string[]>();
private string administratorRoleName;
private UserMembership membership;
private UserProfile profile;
private string[] roles;

/// <summary>Initializes a new instance of the <see cref="UserInfo"/> class.</summary>
public UserInfo()
Expand Down Expand Up @@ -206,26 +206,24 @@ public string[] Roles
{
get
{
if (this.roles == null)
return this.roles.GetOrAdd(this.PortalID, i =>
{
var socialRoles = this.Social.Roles;
if (socialRoles.Count == 0)
{
this.roles = new string[0];
return new string[0];
}
else
{
this.roles = (from r in this.Social.Roles
where
r.Status == RoleStatus.Approved &&
(r.EffectiveDate < DateTime.Now || Null.IsNull(r.EffectiveDate)) &&
(r.ExpiryDate > DateTime.Now || Null.IsNull(r.ExpiryDate))
select r.RoleName)
return (from r in this.Social.Roles
where
r.Status == RoleStatus.Approved &&
(r.EffectiveDate < DateTime.Now || Null.IsNull(r.EffectiveDate)) &&
(r.ExpiryDate > DateTime.Now || Null.IsNull(r.ExpiryDate))
select r.RoleName)
.ToArray();
}
}

return this.roles;
});
}

set
Expand Down

0 comments on commit ae9ca40

Please sign in to comment.