예제 #1
0
        public ActionResult SignupOrLogin()
        {
            UserEntity entity = new UserEntity();

            if (entity.UserExist(Request.Form["username"]))
            {
                if (entity.CheckPassword(Request.Form["username"], Request.Form["password"]))
                {
                    User myUser = entity.GetUserFromUsername(Request.Form["username"]);
                    Session["LoggedUser"] = myUser;
                    Session["LoggedASP"]  = true;
                    if (!String.IsNullOrEmpty(myUser.TwitterToken))
                    {
                        Session["LoggedTwitter"] = true;
                    }
                }
                else
                {
                    Session["ErrorLogin"] = true;
                }
                return(Redirect(Request.UrlReferrer.ToString()));
            }
            else
            {
                entity.AddUser(Request.Form["username"], Request.Form["password"]);
                User myUser = entity.GetUserFromUsername(Request.Form["username"]);
                Session["LoggedUser"] = myUser;
                Session["LoggedASP"]  = true;
                return(Redirect(Request.UrlReferrer.ToString()));
            }
        }