I've created an small fleet management app and with the help of tutorials and materials I've found on the Microsoft website and other.
I managed to implement the User Management services (did not create the project with Authentication from the start) and can now create new Users and manage them from the interface, although I created an "Admin" Role and assigned it to admin account (through Startup.cs) , I'm having a hard time creating an UI to manage the Roles (create, modify, delete, assign roles to users). I've searched for 3 days already and cannot find a proper tutorial on how to use the RoleManager to create a controller and views for it.
Can anyone point me in the right direction?
I'm using ASP.NECore.All 2.0.6 & EF Core 2.1.1
The AccountController:
public class AccountController : Controller
{
private readonly UserManager<ApplicationUser> _userManager;
private readonly SignInManager<ApplicationUser> _signInManager;
private readonly IEmailSender _emailSender;
private readonly ILogger _logger;
public AccountController(
UserManager<ApplicationUser> userManager,
SignInManager<ApplicationUser> signInManager,
IEmailSender emailSender,
ILogger<AccountController> logger)
{
_userManager = userManager;
_signInManager = signInManager;
_emailSender = emailSender;
_logger = logger;
}
The ManageController:
public class ManageController : Controller
{
private readonly UserManager<ApplicationUser> _userManager;
private readonly SignInManager<ApplicationUser> _signInManager;
private readonly IEmailSender _emailSender;
private readonly ILogger _logger;
private readonly UrlEncoder _urlEncoder;
private const string AuthenticatorUriFormat = "otpauth://totp/{0}:{1}?secret={2}&issuer={0}&digits=6";
private const string RecoveryCodesKey = nameof(RecoveryCodesKey);
public ManageController(
UserManager<ApplicationUser> userManager,
SignInManager<ApplicationUser> signInManager,
IEmailSender emailSender,
ILogger<ManageController> logger,
UrlEncoder urlEncoder)
{
_userManager = userManager;
_signInManager = signInManager;
_emailSender = emailSender;
_logger = logger;
_urlEncoder = urlEncoder;
}
The rest of the actions are the default ones, that you get when creating a new project with Individual Accounts Authentication.