Пример #1
0
        public ActionResult Login(string uname, string pass)
        {
            if (ModelState.IsValid)
            {
                SessionController s = new SessionController();
                try
                {
                    UserModel um = db.Umodel.Find(uname);

                    string hashPw = hash.HashPassword(pass, um.salt);

                    UserModel User = db.Umodel.Single(usr => usr.Username == uname &&
                                                      usr.password == hashPw);

                    FormsAuthentication.SetAuthCookie(User.Username, true);

                    // Session["Role"] = Urole;
                    Session["Uname"]  = User.Username;
                    Session["ProPic"] = User.ProfilePic;

                    return(RedirectToAction("Home", "Home"));
                }
                catch (System.InvalidOperationException e)
                {
                    ViewBag.errorMsg = "error";
                    return(View());
                }
            }
            else
            {
                ViewBag.errorMsg = "error";
                return(View());
            }
        }
Пример #2
0
        public ActionResult Login(string uname, string pass)
        {

            if (ModelState.IsValid)
            {
                SessionController s = new SessionController();
                try
                {
                    UserModel um = db.Umodel.Find(uname);

                    string hashPw = hash.HashPassword(pass, um.salt);

                    UserModel User = db.Umodel.Single(usr => usr.Username == uname
                        && usr.password == hashPw);

                    UserRole role = s.GetUserValidity(User);

                    string Urole = "";

                    if (role == UserRole.Admin)
                    {
                        Urole = "Admin";
                    }
                    else if (role == UserRole.PManager)
                    {
                        Urole = "PManager";
                    }
                    else if (role == UserRole.Developer)
                    {
                        Urole = "Developer";
                    }
                    else if (role == UserRole.ScrumMaster)
                    {
                        Urole = "ScrumMaster";
                    }
                    else
                    {
                        ViewBag.errorMsg = "error";
                        return View();
                    }

                    FormsAuthentication.SetAuthCookie(User.Username, true);

                    Session["Role"] = Urole;
                    Session["Uname"] = User.Username;
                    Session["ProPic"] = User.ProfilePic;
                  
                    return RedirectToAction("Home", "Home");
                }
                catch (System.InvalidOperationException e)
                {
                    ViewBag.errorMsg = "error";
                    return View();
                }
            }
            else
            {
                ViewBag.errorMsg = "error";
                return View();
            }
        }
Пример #3
0
        public ActionResult login(string uname, string pass)
        {
            if (ModelState.IsValid)
            {
                SessionController s = new SessionController();
                //  try
                // {
                UserModel um = db.Umodel.Find(uname);

                string hashpw = hash.HashPassword(pass, um.salt);

                // Debug.WriteLine("ddddddddddddddddddd  " + "ss " + um.salt
                // + " pass " + hashpw);

                UserModel User = db.Umodel.Single(usr => usr.Username == uname &&
                                                  usr.password == hashpw);

                UserRole role = s.GetUserValidity(User);

                string Urole = "";

                if (role == UserRole.Admin)
                {
                    Urole = "Admin";
                }
                else if (role == UserRole.PManager)
                {
                    Urole = "PManager";
                }
                else if (role == UserRole.Developer)
                {
                    Urole = "Developer";
                }
                else
                {
                    ViewBag.errorMsg = "error";
                    return(View());
                }

                FormsAuthentication.SetAuthCookie(User.Username, true);

                Session["Role"]   = Urole;
                Session["Uname"]  = User.Username;
                Session["ProPic"] = User.ProfilePic;

                //UserModel us = db.Umodel.Find(uname);
                //string sal = hash.CreateSalt();
                //string p = hash.HashPassword(pass, sal);
                //us.password = p;
                //us.salt = sal;
                //if (ModelState.IsValid)
                //{
                //    db.Entry(us).State = EntityState.Modified;
                //    db.SaveChanges();
                //}
                //Debug.WriteLine("ddddddddddddddddddd  " + "ss " + sal + "
                //pass " + p);
                return(RedirectToAction("Home", "Home"));
                //  }
                //  catch (System.InvalidOperationException e)
                //  {
                //      ViewBag.errorMsg = "error";
                //     return View();
                //  }
            }
            else
            {
                ViewBag.errorMsg = "error";
                return(View());
            }
        }