Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

User Roles and Authentication.

$
0
0

Currently spending my time at home building an Application in MVC ASP.Net Core for a college assignment. I've managed to get both a login and registration form working and I'm now looking at User Roles and Authentication. Just looking for some guidance on the best way of doing this.

Currently I have a 'Roles' field entered into my DB with either 'Admin' and 'User', I then made an 'Admin' and 'Users' Controller linking them to different pages:

[Authorize(Roles="Admin")]
    public class AdminController : Controller
    {
        private readonly DefaultContext _context;
        public AdminController(DefaultContext context)
        {
            _context = context;
        }
        public IActionResult Index()
        {
            return View();
        }
    }

I'm not quite sure on how I go about checking the [Authorize(Roles="Admin")]  to the 'Roles' column within my database? 


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>