• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# LogOnModel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中LogOnModel的典型用法代码示例。如果您正苦于以下问题:C# LogOnModel类的具体用法?C# LogOnModel怎么用?C# LogOnModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LogOnModel类属于命名空间,在下文中一共展示了LogOnModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: AjaxLogin

 public ActionResult AjaxLogin(LogOnModel model)
 {
     if (ModelState.IsValid)
     {
         if (LoginValidate(model))
         {
             return Content("succeed");
         }
         ModelState.AddModelError("", "用户名或密码不正确。");
     }
     return View(model);
 }
开发者ID:dalinhuang,项目名称:college_vod,代码行数:12,代码来源:AccountController.cs


示例17: Auth

 public static bool Auth(LogOnModel model)
 {
     MongoWorker _mongo = new MongoWorker();
     var doc = _mongo.GetDocument<User>(MongoCollections.UserCollection, Query.EQ("Email", model.Email));
     if (doc != null)
     {
         string hash = Encoding.UTF8.GetString(SHA1.Create().ComputeHash(Encoding.UTF8.GetBytes(doc.ID.ToString() + model.Password)));
         if (hash == doc.Password)
         {
             return true;
         }
     }
     return false;
 }
开发者ID:paradise,项目名称:test,代码行数:14,代码来源:AccountWork.cs


示例18: LogOn

        public JsonResult LogOn(LogOnModel model)
        {
            var user = storeDB.Users.AsEnumerable()
                            .Where(w => w.UserName == model.UserName && w.Password == model.Password)
                            .Select(s => s.User_id).SingleOrDefault();
            if (user == 0)
            {
                Session["userId"] = null;
            }
            else
            {
                Session["userId"] = user;
            }

            return Json(user);
        }
开发者ID:Bjsmarts-Public,项目名称:MvcMusicStoreSharepointAngular,代码行数:16,代码来源:AccountController.cs


示例19: JsonLogOn

        public JsonResult JsonLogOn(LogOnModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                if (Membership.ValidateUser(model.UserName, model.Password))
                {
                    FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                    return Json(new { success = true, redirect = returnUrl });
                }
                else
                {
                    ModelState.AddModelError("", "The user name or password provided is incorrect.");
                }
            }

            // If we got this far, something failed
            return Json(new { errors = GetErrorsFromModelState() });
        }
开发者ID:rsatter,项目名称:WebLOBApp,代码行数:18,代码来源:AccountController.cs


示例20: LogOn

        //
        // GET: /Account/LogOn
        public ActionResult LogOn(LogOnModel model, string returnUrl)
        {
            ProjectPlannerContext ctx = new ProjectPlannerContext();

            if (ModelState.IsValid)
            {
                string passwordHash = model.Password.GetHash();
                if(ctx.Users.SingleOrDefault(p => (p.Username.Equals(model.Username) && p.PasswordHash.Equals(passwordHash))) != null)
                {
                    FormsAuthentication.SetAuthCookie(model.Username, model.RemindMe);

                    return Redirect(returnUrl);
                }

                ViewBag.Error = "Couldn't find the user or password did not match!";
            }

            return View();
        }
开发者ID:ImaginationOverflow,项目名称:ProjectPlanner,代码行数:21,代码来源:AccountController.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# LogSeverity类代码示例发布时间:2022-05-24
下一篇:
C# LogMessageType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap