How correctly implement role-based authorization with ASP.NET Core 6 with CoreAdmin NuGet package?

Viewed 17

Account/Login:

public async Task<IActionResult> Login(LoginViewModel model, string returnUrl)
{
    model.ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();

    if (ModelState.IsValid)
    {
        var result = await _signInManager.PasswordSignInAsync(
            model.UserName, model.Password, model.RememberMe, false);
        if (result.Succeeded)
        {
            if (!string.IsNullOrEmpty(returnUrl) && Url.IsLocalUrl(returnUrl))
            {
                return Redirect(returnUrl);
            }

            return RedirectToAction("Index", "Home");
        }

        ModelState.AddModelError("", "Invalid Login Attempt!!");
    }

    return View(model);
}
0 Answers
Related