Last post Mar 14, 2017 02:05 PM by Dmitry Sikorsky
Mar 12, 2017 02:11 AM|Shuklaji123|LINK
I need to make a single registration form and allow these 4 designations to reach to their dashboard by the same form filling . How can I do this ?Thanks in advance !!!!!!!!!!!!!!!
Mar 12, 2017 06:49 AM|anurajp|LINK
How the system will know a user is admin, hr, student, teacher etc?
Mar 12, 2017 06:59 AM|Shuklaji123|LINK
That i do not know. I was asked to make a registration form in which the user, admin and hr will register and navigate to different pages. I need to apply 4 tier architecture in this....
Mar 12, 2017 02:33 PM|anurajp|LINK
I am not asking from the implementation perspective. What is your logic? Flow? If a user and admin are registering from the same form, how the system will differentiate this user is admin and this user is a normal user? First, think about logic, than thinking
about the architecture or design.
Mar 13, 2017 12:48 PM|Shuklaji123|LINK
That logic only , ia am asking. If everthing I had known, I had not asked this question here, directly implemented.....You need to tell me all, if you know it,else leave it, somebody else will answer... Thanks
Mar 13, 2017 04:07 PM|Dmitry Sikorsky|LINK
Hi! It is easy to fix. When the user is logged in you can check the role claim and redirect the user to the specific dashboard. Or you can use the same dashboard and show different content depending on the role. It is very easy to check whether user belongs
to some role or not. I can share more info if this approach suits your needs.
Mar 14, 2017 03:21 AM|Shuklaji123|LINK
Yes, U have hit the bull's eye. Thank God !!!!!!!!!!!!!!!!!!!! Please share the approach, how to do it. Many Thanks
Mar 14, 2017 08:59 AM|Dmitry Sikorsky|LINK
So, it is really very easy. If you create the default ASP.NET Core web application with single user auth you will have AccountController created. There is Login action. You can modify the Post part of that action a bit and add role check:
var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, lockoutOnFailure: false);
_logger.LogInformation(1, "User logged in.");
Now you will redirect all administrators to someotherurl, but all other users back to returnurl.
In is still very easy to check the user role in the view:
You can add this code in any view including partial ones.
Mar 14, 2017 11:40 AM|Shuklaji123|LINK
thank you for the answer, but I am not working in the mvc 5 now. i need your help on simple mvc5 now. Thanks
Mar 14, 2017 12:30 PM|Dmitry Sikorsky|LINK
Sorry, don't understand the question. Are you working with asp.net core mvc? The approach is the same for the old asp.net mvc and for the new asp.net core mvc.
Mar 14, 2017 01:44 PM|Shuklaji123|LINK
I want this solution in simple asp.net web application, that's it....
Mar 14, 2017 02:05 PM|Dmitry Sikorsky|LINK
But you can use it in any asp.net application. You can find the User object in the HttpContext. What is 'simple asp.net application' in your case? Is it asp.net core? Or old asp.net web application with web pages? Or what? I will try to give more specific
answer related to your case.