简体   繁体   中英

Best practice to check data of a user before logging in

There is a table that keeps a user's details. An admin can lock this user by setting the column called locked. Once the user is locked they cannot login. I am using The WebSecurity.Login to login. As of now I am letting the user to login, then it checks if they are not locked and if they are instead of home page they are redirected to locked page.

What is the best practice that I can use so that the user doesnt gets logged in, check the field and gets redirected. This is in MVC 4

Thanks in advance...

Maybe I misunderstand you.. but currently you have something like this:

Membership.LoginUser(userName, password);

if (CurrentUser.IsLocked) {
    RedirectUser();
}

..can you not just replace it with something like this?:

var user = Membership.GetUser(userName, password);
if (user.IsLocked) {
    Redirect();
}
else {
    Membership.LoginUser(user);
}

... ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM