本文整理汇总了C#中LogOnModel类的典型用法代码示例。如果您正苦于以下问题:C# LogOnModel类的具体用法?C# LogOnModel怎么用?C# LogOnModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LogOnModel类属于命名空间,在下文中一共展示了LogOnModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LogOn
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
Session["Notification"] = "";
if (ModelState.IsValid)
{
KIREIP.Core.Manager.UserManager CM = new KIREIP.Core.Manager.UserManager();
KIREIP.Core.DAL.Login usr = CM.LoginUser(model.UserName, model.Password);
if (usr != null)
{
FormsAuthentication.Initialize();
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, usr.UserName.ToString(), DateTime.Now, DateTime.Now.AddMinutes(30), model.RememberMe, FormsAuthentication.FormsCookiePath);
string hash = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, hash);
if (ticket.IsPersistent) cookie.Expires = ticket.Expiration;
Response.Cookies.Add(cookie);
if ((!String.IsNullOrEmpty(returnUrl)) && returnUrl.Length > 1)
return Redirect(returnUrl);
else
{
return RedirectToAction("Index", "Message");
}
}
else
{
ModelState.AddModelError("", "Incorrect user name or password.");
}
}
// If we got this far, something failed, redisplay form
return View(model);
}
示例2: LogOn
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
if (ModelState.IsValid)
{
if (MembershipService.ValidateUser(model.UserName, model.Password))
{
FormsService.SignIn(model.UserName, model.RememberMe);
if (Url.IsLocalUrl(returnUrl))
{
return Redirect(returnUrl);
}
else
{
return RedirectToAction("Index", "Home");
}
}
else
{
ModelState.AddModelError("", "The user name or password provided is incorrect.");
}
}
// If we got this far, something failed, redisplay form
return View(model);
}
示例3: LogOn
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
if (ModelState.IsValid)
{
UsuarioModel user = null;
if (new Usuario().AutenticaUsuario(model.UserName, model.Password, ref user))
{
Session["login"] = user;
FormsAuthentication.SetAuthCookie(model.UserName, false);
if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
&& !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
{
return Redirect(returnUrl);
}
else
{
return RedirectToAction("Index", "Home");
}
}
else
{
ModelState.AddModelError("", "Senha e usuário incorretos ou você não possui permissão para acessar o sistema.");
}
}
return View(model);
}
示例4: LogOn
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
if (ModelState.IsValid)
{
try
{
UserSession = new UserSession(model.UserName, model.Password);
UserSession.Authenticate();
FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
if (Url.IsLocalUrl(returnUrl))
{
return Redirect(returnUrl);
}
return RedirectToAction("Index", "Home");
}
catch (AuthenticationException)
{
ModelState.AddModelError("", "The user name or password provided is incorrect.");
}
}
// If we got this far, something failed, redisplay form
return View(model);
}
示例5: LogOn
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
if (ModelState.IsValid)
{
if (MembershipService.ValidateUser(model.UserName, model.Password))
{
FormsService.SignIn(model.UserName, model.RememberMe);
if (!String.IsNullOrEmpty(returnUrl))
{
return Redirect(returnUrl);
}
else
{
return RedirectToAction("Index", "Home");
}
}
else
{
ModelState.AddModelError("", "El nombre de usuario o la contraseña especificados son incorrectos.");
}
}
// Si llegamos a este punto, es que se ha producido un error y volvemos a mostrar el formulario
return View(model);
}
示例6: LogOn
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
if (ModelState.IsValid)
{
if (Membership.ValidateUser(model.UserName, model.Password))
{
FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
&& !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
{
return Redirect(returnUrl);
}
else
{
return RedirectToAction("Index", "Home");
}
}
else
{
ModelState.AddModelError("", "The user name or password provided is incorrect.");
}
}
// If we got this far, something failed, redisplay form
return View(model);
}
示例7: LogOn
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
if (ModelState.IsValid)
{
if (System.Web.Security.FormsAuthentication.Authenticate(model.UserName, model.Password))
{
FormsService.SignIn(model.UserName, model.RememberMe);
if (!String.IsNullOrEmpty(returnUrl))
{
return Redirect(returnUrl);
}
else
{
return RedirectToAction("Index", "Home");
}
}
else
{
ModelState.AddModelError("", "The user name or password provided is incorrect.");
}
}
// If we got this far, something failed, redisplay form
return View(model);
}
示例8: LogIn
public virtual ActionResult LogIn(LogOnModel model)
{
model.NavigationLocation = new string[] { "Home", "Login" };
model.RememberMe = true;
return View(model);
}
示例9: LogOn
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
if (ModelState.IsValid)
{
if (Membership.ValidateUser(model.UserName, model.Password))
{
//Membership.DeleteUser(model.UserName, true);
FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
&& !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
{
return Redirect(returnUrl);
}
else
{
return RedirectToAction("Index", "CheatNotes");
}
}
else
{
ModelState.AddModelError("", "Неправильный пароль или имя пользователя.");
}
}
// If we got this far, something failed, redisplay form
return View(model);
}
示例10: LogOnCommand
public FubuContinuation LogOnCommand(LogOnModel input)
{
if (_membershipService.UserExists(input.UserName, input.Password)) {
_authenticationContext.ThisUserHasBeenAuthenticated(input.UserName, input.RememberMe);
return FubuContinuation.RedirectTo<IndexInput>();
}
return FubuContinuation.TransferTo<LogOnInput>();
}
示例11: LogOn
public ActionResult LogOn()
{
var viewModel = new LogOnModel
{
PageTitle = "Авторизация"
};
return View(viewModel);
}
示例12: LogOn
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
int logOnAttempt = Convert.ToInt32(Session["LogOnAttempt"]);
const int logOnAttemptLock = 6;
const int logOnAttemptCaptcha = 3;
ViewBag.LOG_ON_ATTEMPT_LOCK = logOnAttemptLock;
ViewBag.LOG_ON_ATTEMPT_CAPTCHA = logOnAttemptCaptcha;
if (ModelState.IsValid)
{
if ((logOnAttempt >= logOnAttemptCaptcha) &&
(Session["Captcha"] == null || Session["Captcha"].ToString() != model.Captcha))
{
ModelState.AddModelError("Captcha", @"Неверно указан результат вычисления");
}
if (ModelState.IsValid)
{
if (_securityUserService.ValidateUser(model.Login, model.Password))
{
FormsAuthentication.SetAuthCookie(model.Login, model.RememberMe);
Session["LogOnAttempt"] = 0;
if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
&& !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
{
return Redirect(returnUrl);
}
return RedirectToAction("Index", "Home");
}
ModelState.AddModelError("", @"Введено неправильное имя пользователя или пароль");
}
}
else
{
ModelState.AddModelError("", @"Некорректный логин или пароль");
}
if (logOnAttempt >= logOnAttemptLock)
{
ModelState.AddModelError("",
String.Format(
"После {0} неудачных попыток войти, браузер должен быть закрыт. Пожалуйста, обратись к администратору за детальной информации о вашем входе.",
logOnAttemptLock));
}
Session["LogOnAttempt"] = logOnAttempt + 1;
model.Captcha = "";
ViewBag.ReturnUrl = returnUrl;
return View(model);
}
示例13: ValidateLogOn
public static bool ValidateLogOn(LogOnModel model)
{
if (Membership.ValidateUser(model.UserName, model.Password) && !profileDB.Users.Find(model.UserName).blocked)
{
FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
printLog("User '" + model.UserName + "' logged in");
return true;
}
return false;
}
示例14: Index
public ActionResult Index(LogOnModel model)
{
bool authSuc = AccountController.ValidateLogOn(model);
if (!authSuc)
{
ModelState.AddModelError("", WJP_Resources.Lang.IncorrectLoginOrPass);
}
ViewBag.LoggedIn = authSuc;
ViewBag.UserName = model.UserName;
return View(model);
}
示例15: LogOn
//
// GET: /Account/LogOn
public ActionResult LogOn()
{
//Provided for simplicity with the sample
var vm = new LogOnModel
{
UserName = "Administrator",
Password = "password123!",
RememberMe = false
};
return View(vm);
}