I have a need to use (and validate) both UserName, and Business Name as part of a Login Process. So that my Login Form takes in CompanyId, UserId and Password.
This all works fine up to the point where I call
if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
I can't just add in model.Companyid as a parameter to that method, I am hoping that it is just possible to extend this, or do I need to write my own Login method from scratch?
Of course!
public class ExtendWebSecurity
{
public static boolean Login(
this WebSecurity ws,
string username,
string password,
boolean persist,
int companyId)
{
// Add your logic
return ws.Login(username, password, persistCookie: persist);
}
}
Note, this has not been tested.
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.