Beispiel #1
0
 public ActionResult Login(LoginViewModel loginViewModel)
 {
     try
     {
         var user = new User
             {
                 Email = loginViewModel.UserNameOrEmail,
                 Password = loginViewModel.Password,
                 UserName= loginViewModel.UserNameOrEmail
             };
         var result = _userLogic.AuthenticateUser(user);
         if (result)
         {
             user = _userLogic.GetByEmailAndPassword(user.Email, user.Password) ??
                        _userLogic.GetByUserNameAndPassword(user.UserName, user.Password);
             _cookieHelper.SetAuthCookie(Convert.ToString(user.UserId), false);
             return new RedirectResult(Url.Action("Index", "Project"));
         }
         loginViewModel.PromptInfo = "Incorrect username or password.";
         return View(loginViewModel);
     }
     catch (Exception)
     {
         return View("Error");
     }
 }
Beispiel #2
0
        public ActionResult Login()
        {
            //for init Data
            var name = _userLogic.Get(1).UserName;

            var loginViewModel = new LoginViewModel();
            return View(loginViewModel);
        }
Beispiel #3
0
 public User ToUserFromLoginViewModel(LoginViewModel loginViewModel)
 {
     return new User
         {
             Email = loginViewModel.Email,
             Password = loginViewModel.Password
         };
 }