Ejemplo n.º 1
0
 public ActionResult Login(ForumViewModel data, string returnUrl)
 {
     if (!string.IsNullOrEmpty(data.Users?.DisplayName) && !string.IsNullOrEmpty(data.Users?.Password))
     {
         var userAcount = new AccountVM();
         var user       = userAcount.FindUser(data.Users.DisplayName);
         var exists     = Security.VerifyHashedPassword(user?.Password, data.Users.Password);
         if (exists && !string.IsNullOrEmpty(user?.Name))
         {
             new Ts3Principal(user);
             SessionPresister.UserName = user.Name;
             SessionPresister.UserId   = user.Id;
             return(new RedirectResult(returnUrl));
         }
         else
         {
             ViewBag.ErrorMsg = "Podany login lub hasło jest nieprawidłowe.";
         }
     }
     return(View("Index"));
 }