コード例 #1
0
        private void ParsingLoginNameOrEmail(LoginViewModel loginModel)
        {
            var z = loginModel.NameOrEmail.IndexOf('@'); ;

            if (loginModel.NameOrEmail.IndexOf('@') == -1)
                loginModel.Name = loginModel.NameOrEmail;
            else
                loginModel.Email = loginModel.NameOrEmail;
        }
コード例 #2
0
        public ActionResult ForgotThePassword(LoginViewModel loginModel)
        {
            dynamic email = new Email("ForgotThePassword");
            email.To = "*****@*****.**";
            email.FunnyLink = "Hello Alex :)";
            email.Send();

            return View();
        }
コード例 #3
0
        public ActionResult Index(LoginViewModel loginModel, string returnUrl)
        {
            if (String.IsNullOrEmpty(loginModel.NameOrEmail) && String.IsNullOrEmpty(loginModel.Password))
                return View();

            ReturnUrl = returnUrl;
            Index(loginModel, returnUrl, true);

            if (string.IsNullOrEmpty(ReturnUrl))
                return View();
            else
                return Redirect(ReturnUrl);// ?? Url.Action("Index", "Home"));
        }
コード例 #4
0
        public ActionResult Index(LoginViewModel loginModel, bool IsRegister)
        {
            // IsRegister = IsRegister ?? false;

            if (IsRegister)
            {
                if (!string.IsNullOrEmpty(loginModel.NameOrEmail))
                    ParsingLoginNameOrEmail(loginModel);
                return RedirectToAction("User", "Register", new { Name = loginModel.Name, Email = loginModel.Email });
            }
            else
            {
                return RedirectToAction("Index", "Login", new
                {
                    NameOrEmail = loginModel.NameOrEmail,
                    Password = loginModel.Password,
                    RememberMe = loginModel.RememberMe,
                    returnUrl = Request.UrlReferrer.OriginalString,
                });
            }
        }
コード例 #5
0
        public ActionResult Index(LoginViewModel loginModel, string returnUrl, bool? a = null)
        {
            DataManager manager = new DataManager();
            string name = "";
            int id = -1;
            bool have = manager.CheckUserLogin(loginModel, ref name, ref id);

            if (have)
            {
                FormsAuthentication.SetAuthCookie(name, loginModel.RememberMe);
                Storage.SaveCookieID(Storage.aliasUserID, id.ToString(), DateTime.Now.AddYears(1));

                return Redirect(returnUrl ?? Url.Action("Index", "Home"));
            }
            else
            {
                loginModel.Password = null;
                ReturnUrl = "";
                ModelState.AddModelError("LoginAndPassword_DoesNotMatch", "Oops, either name or password does not match, try again");
                return View();
            }
        }