Пример #1
0
        public PartialViewResult LogOn(LogOnModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                if (Membership.ValidateUser(model.Phone, model.Password))
                {
                    FormsAuthentication.SetAuthCookie(model.Phone, model.RememberMe);

                    Client user = Manager.GetClientByPhone(model.Phone);

                    UserData userData = new UserData
                    {
                        Phone = user.Phone,
                        ID = user.ClientId,
                        FullName = user.FullName
                    };

                    //Nadpisuje cookie dla przechowywania dodatkowych informacji
                    Response.SetAuthCookie(model.Phone, true, userData);

                    //if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
                    //    && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                    //{
                    //    return Redirect(returnUrl);
                    //}
                    //else
                    //{
                    //    return RedirectToAction("Index", "Home");
                    //}
                    return PartialView("SignInSuccessPartial");
                }
                else
                {
                    ModelState.AddModelError("", "Nieprawidłowe telefon lub hasło!");
                }
            }

            return PartialView("SignInPartial",model);
        }
Пример #2
0
        private void LogInUser(Client client)
        {
            FormsAuthentication.SetAuthCookie(client.Phone, true);

            UserData userData = new UserData
            {
                Phone = client.Phone,
                ID = client.ClientId,
                FullName = client.FullName
            };

            Manager.UpdateLastLoginDate(client.ClientId);

            //Nadpisuje cookie dla przechowywania dodatkowych informacji
            Response.SetAuthCookie(client.Phone, true, userData);
        }