Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

Checking if User Logged On To Allow Access to Controller (MVC using VB)

$
0
0

My application was created using MVC4 and Intranet Application scaffolding.

The users register using the default Account Model/Controller scaffolding provided when the application was created.  i.e.

WebSecurity.CreateUserAndAccount(model.UserName, model.Password)
WebSecurity.Login(model.UserName, model.Password)

The application uses an external DB that keeps track of the users that are registered/authorized to log on.  The DB has a table for additional user information.

I would like to check the user name from my Controllers as it allows me to refer back to the DB and check if the user is allowed to access certain tables in the DB.

In my Account Controller's Login Method I have:

If ModelState.IsValid AndAlso WebSecurity.Login(model.UserName, model.Password, persistCookie:=False) Then

My question then is : how can I access this "model" from another Controller?

Said Controllers already use the <Authorize> tag/attribute to make force the user to log on.  I would like to be able to see the user's username which I save in my external DB.


Viewing all articles
Browse latest Browse all 4737

Trending Articles



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