当前位置: 首页>>代码示例>>C#>>正文


C# LogOnModel类代码示例

本文整理汇总了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);
        }
开发者ID:Tia-Demo,项目名称:KendoVS4,代码行数:32,代码来源:AccountController.cs

示例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);
        }
开发者ID:Joebeazelman,项目名称:rebelcmsxu5,代码行数:25,代码来源:AccountController.cs

示例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);
        }
开发者ID:Marksys,项目名称:CAD,代码行数:27,代码来源:AccountController.cs

示例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);
        }
开发者ID:hhariri,项目名称:SimpleTrack,代码行数:25,代码来源:AccountController.cs

示例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);
        }
开发者ID:roysalor,项目名称:Curso-ASP.NET,代码行数:25,代码来源:AccountController.cs

示例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);
        }
开发者ID:JustGiving,项目名称:JustGiving.Recruitment.QaAutomation,代码行数:26,代码来源:AccountController.cs

示例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);
        }
开发者ID:jimlawruk,项目名称:lawruk.com,代码行数:25,代码来源:AccountController.cs

示例8: LogIn

        public virtual ActionResult LogIn(LogOnModel model)
        {
            model.NavigationLocation = new string[] { "Home", "Login" };
            model.RememberMe = true;

            return View(model);
        }
开发者ID:cherther,项目名称:SongSearch,代码行数:7,代码来源:AccountController.cs

示例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);
        }
开发者ID:aleksey-pyatlin,项目名称:testRep,代码行数:27,代码来源:AccountController.cs

示例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>();
 }
开发者ID:emiaj,项目名称:FubuMvcSparkProjectTemplate,代码行数:8,代码来源:LogOnEndpoint.cs

示例11: LogOn

        public ActionResult LogOn()
        {
            var viewModel = new LogOnModel
            {
                PageTitle = "Авторизация"
            };

            return View(viewModel);
        }
开发者ID:sukhanov,项目名称:Storage,代码行数:9,代码来源:AccountController.cs

示例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);
        }
开发者ID:altaricka,项目名称:vDesign,代码行数:56,代码来源:AccountController.cs

示例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;
        }
开发者ID:KACAH,项目名称:WEB-Java-Project,代码行数:11,代码来源:AccountController.cs

示例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);
        }
开发者ID:KACAH,项目名称:WEB-Java-Project,代码行数:12,代码来源:HomeController.cs

示例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);
        }
开发者ID:GProulx,项目名称:Glimpse,代码行数:15,代码来源:AccountController.cs


注:本文中的LogOnModel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。