Last post Jul 30, 2018 12:49 PM by mudassarkhan
Jul 30, 2018 09:33 AM|mazhar khan india|LINK
Using scaffolding I have two table
Username Password Email RoleId
Mazhar xyz firstname.lastname@example.org 1
Admin xyz email@example.com 2
Base on email and password user and admin login and they will get there page.
I need login controller code to achieve this. Thank you in advance
Jul 30, 2018 11:19 AM|PatriceSc|LINK
Not sure to get it. You want to automatically add a user to the Admin role if his mail address starts with "admin@" ? Seems weird. It would allow any user with the correct criteria gain admin access to your app.
IMO only a registered admin should be able to take this kind of decision. users is using an
firstname.lastname@example.org mail address ???
Else it seems a sample test and then it depends which API you are using. Try perhaps https://msdn.microsoft.com/en-us/library/dn468058(v=vs.111).aspx
Edit: or maybe with an additional check so that it can happen only if not other user has admin access ???
Jul 30, 2018 11:48 AM|mudassarkhan|LINK
Role based Security in ASP.Net MVC
Jul 30, 2018 11:52 AM|mazhar khan india|LINK
As you given link, that is not related to code first, i think its database first approach?
Jul 30, 2018 12:24 PM|mudassarkhan|LINK
Yes. It is Database First.
Jul 30, 2018 12:46 PM|mazhar khan india|LINK
I asked for code first mudassar.
Jul 30, 2018 12:49 PM|mudassarkhan|LINK
There is no ready example for Code- first.
You can implement your Code First approach and then follow the Forms Authentication and Role Based Security explained in the article.