Esempio n. 1
0
 public ActionResult Login()
 {
     if (HttpContext.User.Identity.IsAuthenticated)
     {
         AppUser user = _appUserRepository.FindByUserName(User.Identity.Name);
         if (user.Status != Status.Passive)
         {
             if (user.Role == Role.Admin)
             {
                 string cookie = user.UserName;
                 FormsAuthentication.SetAuthCookie(cookie, true);
                 Session["UserName"]  = user.UserName;
                 Session["ImagePath"] = user.UserImage;
                 return(Redirect("/Admin/Home/Index"));
             }
             else if (user.Role == Role.Author)
             {
                 string cookie = user.UserName;
                 FormsAuthentication.SetAuthCookie(cookie, true);
                 Session["UserName"]  = user.UserName;
                 Session["ImagePath"] = user.UserImage;
                 return(Redirect("/Author/Home/Index"));
             }
             else
             {
                 string cookie = user.UserName;
                 FormsAuthentication.SetAuthCookie(cookie, true);
                 Session["UserName"]  = user.UserName;
                 Session["ImagePath"] = user.UserImage;
                 return(Redirect("/Member/Home/Index"));
             }
         }
         else
         {
             ViewData["Error"] = "Username  or password are wrong..1";
             return(View());
         }
     }
     return(View());
 }