ApplicationUser fails

I have just updated the last version of Radzen.

I'm using ActiveDirectory.

The ApplicationUser class derives from IdentityUser but the usigne line

using Microsoft.AspNetCore.Identity;

lacks.

So. I'unable to run the app from the visual designer

...
using System.Runtime.Serialization;

namespace Aserp.Models

{

public partial class ApplicationUser : **IdentityUser**

{

    [NotMapped]

    public IEnumerable<string> RoleNames { get; set; }

...

& More.

In the Login.razor

@inject UserManager UserManager

@inject SignInManager SignInManager

Need also the same import.

Playing with _imports.razor I can resove it but the problem is there.

The issue is fixed and we will release update later today.

Is it possible to fix the security service class with a partial class?
I'm forced to add in exclude list because I have a function to check roles with a custom method.

My SecurityService.custom.cs is not an option without the partial class.

My own policy is Having one of roles from my own roles list is enough.

The supervisors are users & the users are readers.
I need set the user role only for the max level access.

From my SecurityService.Custom.cs

public partial class SecurityService

  • {*

  •    private static ApplicationRole _appRoles = new ApplicationRole();*
    
  •    public ApplicationRole AppRoles => _appRoles;*
    
  •    public bool HasRoleAs(params string[] roles)*
    
  •    {*
    
  •        foreach (var role in roles)*
    
  •        {*
    
  •            if (IsInRole(role)) return true;*
    
  •        }*
    
  •        return false;*
    
  •    }*
    
  •    public bool IsAnonymous => User.Name == ApplicationRole.ANONYMOUS;*
    
  •    public bool IsAdmin => User.Name == ApplicationRole.ADMIN;*
    
  •    public bool IsSYSAdmin => HasRoleAs(AppRoles.SYSAdmins) || IsAdmin;*
    
  •    public bool IsSYSSupervisor => HasRoleAs(AppRoles.SYSSupervisors);*
    
  •    public bool IsSYSUser => HasRoleAs(AppRoles.SYSUsers);*
    

,,,

  • public bool CheckHasARoleAs(ComponentBase component, NavigationManager UriHelper)*
  •    {*
    
  •        System.Attribute[] attrs = System.Attribute.GetCustomAttributes(component.GetType()); *
    
  •        bool ok = true;*
    
  •        foreach (System.Attribute attr in attrs)*
    
  •        {*
    
  •            if (attr is HasRoleAsAttribute)*
    
  •            {*
    
  •               ok = false;*
    
  •                var roles = ((HasRoleAsAttribute)attr).Roles;*
    
  •                foreach (var role in roles.Split(","))*
    
  •                {*
    
  •                    if (IsInRole(role))*
    
  •                    {*
    
  •                        ok = true;*
    
  •                        break;*
    
  •                    }*
    
  •                }*
    
  •                if (!ok)*
    
  •                {*
    
  •                    UriHelper.NavigateTo("/unauthorized", true);*
    
  •                    return false;*
    
  •                }*
    
  •            }*
    
  •        }*
    
  •        return true;*
    
  •    }*
    

...

.
So for authorize pages I have this funtion in each page with a custom attribute

SubEmailAdd.razor.cs

*[HasRoleAs(ApplicationRole.AsSUBUsers)]*
  • public partial class SubEmailAddComponent*
  • {*
  •    protected override void OnInitialized()*
    
  •    {*
    
  •       Security.CheckHasARoleAs(this, UriHelper);*
    
  •    }*
    

...

Best regards.

F RUIZ

The release is already published

The release published works as expected.

For the next release it will be an useful fix add partial to generated SecurityService class.

Thanks.