Select theme:
The current application user is available as the User
property of the SecurityService
class. An instance of this class is available
in Blazor components which Radzen generates from the application pages.
Here is how to inject the SecurityService
in custom classes.
SecurityService
private readonly SecurityService security;
SecurityService
.public MyService(SecurityService security)
{
}
public MyService(SecurityService security)
{
this.security = security;
}
If you are extending one of the services generated by Radzen make sure to invoke the generated constructor and add all existing parameters e.g.
public partial class CrmService
{
private readonly SecurityService security;
public CrmService(/* add the context parameter */CrmContext context, SecurityService security)
: /*invoke the generated constructor */this(context)
{
this.security = security;
}
}
After you have injected the SecurityService
you can use its properties and methods:
var user = security.User;
var isAdmin = security.IsInRole("Administrator");
Radzen is free to use. You can also test the premium features for 15 days.
Download NowSelect theme: