Esempio n. 1
0
        public ActionResult Login([Bind(Include = "UserName,PassWord,Remember")] Models.LoginVM user)
        {
            string txtPassword = user.PassWord;
            string RawPassword;

            Helper.UserContext.Destroy();

            using (var md5Hash = MD5.Create())
            {
                RawPassword = Helper.StringUtils.GetMd5Hash(md5Hash, txtPassword);
                ///RawPassword.ToLower();
            }
            using (var db = new Models.QLBHEntities())
            {
                var CheckUser = db.Users.Where(item => item.f_Username == user.UserName &&
                                               item.f_Password == RawPassword)
                                .FirstOrDefault();
                if (CheckUser != null)
                {
                    Session["isLogin"]     = true;
                    Session["CurrentUser"] = CheckUser;
                    if (user.Remember == true)
                    {
                        Response.Cookies["user_id"].Value = CheckUser.f_ID.ToString();
                        ///System.Diagnostics.Debug.Write(Response.Cookies["user_id"].Value+"\n\n\n");
                        Response.Cookies["user_id"].Expires = DateTime.Now.AddDays(7);
                    }
                    return(RedirectToAction("Index", "Home"));
                }
            }

            ViewBag.MgsErorrAccount = "Sai Tài Khoản Hoặc Mật Khẩu";
            return(View());
        }
Esempio n. 2
0
 public ActionResult Login(Models.LoginVM model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             var _bo = _accountService.VerifyLoginCreds(Infrastructure.BOVMMapper.Map <Models.LoginVM, BO.LoginBO>(model));
             if (_bo != null)
             {
                 Infrastructure.Web.SessionManager.SetLoggedInUserSession(Infrastructure.BOVMMapper.Map <BO.UserLoginResultBO, Models.UserLoginResultVM>(_bo));
                 return(Redirect(Infrastructure.Web.Common.DashboardUrl));
             }
         }
         catch (Exception ex)
         {
             base.LogException(ex);
         }
     }
     else
     {
         // If we got this far, something failed, redisplay form
         ModelState.AddModelError("", "Please enter user name and password.");
     }
     return(View(model));
 }
        public ActionResult Login(Models.LoginVM vm)
        {
            HttpCookie hc = new HttpCookie("softphone");

            hc.Values["employee_id"] = vm.employee_id;
            hc.Values["dn"]          = vm.DN;
            hc.Values["place"]       = vm.Place;
            hc.Values["password"]    = vm.password;
            hc.Values["isemergency"] = vm.IsEmergency.ToString();
            hc.Expires = DateTime.Now.AddDays(+365);
            Response.AppendCookie(hc);

            return(RedirectToAction("Index", "SoftPhoneToolBar"));
        }
        public ActionResult Index(Models.LoginVM vm)
        {
            var appUserName = System.Web.Configuration.WebConfigurationManager.AppSettings["Screen.UserName"];
            var appPWD      = System.Web.Configuration.WebConfigurationManager.AppSettings["Screen.PWD"];

            if (vm.UserName == appUserName && vm.PWD == appPWD)
            {
                HttpCookie hc = new HttpCookie("screen");
                hc.Value = "Y";
                Response.AppendCookie(hc);
                return(RedirectToAction("Show"));
            }

            return(View());
        }
        //
        // GET: /Home/

        public ActionResult Index(string employee_id, string source = "SDI")
        {
            if (string.IsNullOrEmpty(employee_id))
            {
                return(RedirectToAction("Login", "Home"));
            }
            else
            {
                Models.LoginVM vm = new Models.LoginVM();
                vm.employee_id = employee_id;
                vm.DN          = "";
                vm.password    = "";
                vm.IsEmergency = 0;
                if (source == "SDI")
                {
                    HttpCookie hc = new HttpCookie("softphone");
                    hc.Values["employee_id"] = vm.employee_id;
                    hc.Values["dn"]          = vm.DN;
                    hc.Values["place"]       = vm.Place;
                    hc.Values["password"]    = vm.password;
                    hc.Values["isemergency"] = vm.IsEmergency.ToString();
                    hc.Expires = DateTime.Now.AddDays(+365);
                    Response.AppendCookie(hc);
                    return(RedirectToAction("CCForBusiness", "SoftPhoneToolBar"));
                }
                else if (source == "ESD")
                {
                    HttpCookie hc = new HttpCookie("softphoneESD");
                    hc.Values["employee_id"] = vm.employee_id;
                    hc.Values["dn"]          = vm.DN;
                    hc.Values["place"]       = vm.Place;
                    hc.Values["password"]    = vm.password;
                    hc.Values["isemergency"] = vm.IsEmergency.ToString();
                    hc.Expires = DateTime.Now.AddDays(+365);
                    Response.AppendCookie(hc);
                    return(RedirectToAction("CCForBusinessESD", "SoftPhoneToolBar"));
                }
                else
                {
                    return(RedirectToAction("Login", "Home"));
                }
            }
        }
Esempio n. 6
0
        public ActionResult Login(Models.LoginVM model)
        {
            try
            {
                if (true) // ModelState.IsValid
                {
                    if (LogIn(model.UserName, model.Password))
                    {
                        bool isLoggedIn = true;

                        try
                        {
                            // Set the session stuff up
                            HttpContext.Session.SetString(Session.USER, model.UserName);              //"sstraley1"
                            //HttpContext.Session.SetString(Session.TOKEN, model.PersonalAccessToken);  //"sksf7bfglyb5n65wm7csutpnrmxg4kxwdz7b66v6asazp56pgt7q"


//                            var root = _env.ContentRootPath + "\\App_data\\" + HttpContext.Session.GetString(Session.USER);
                            //var root = @"C:\vsts";

                            //var bash = _env.ContentRootPath + "\\App_data\\Git";
//                            var bash = @"C:\Program Files\Git\usr\bin";

                            //HttpContext.Session.SetString(Session.VSTS, root );       //"C:\vsts"
                            //HttpContext.Session.SetString(Session.GIT, bash);     //"C:\Program Files\Git\usr\bin\sh.exe"

                            // find LOCAL VSTS Folder and if not, then make
                            //if (!System.IO.Directory.Exists(HttpContext.Session.GetString(Session.VSTS)))
                            //{
                            //    System.IO.Directory.CreateDirectory(HttpContext.Session.GetString(Session.VSTS));
                            //}

                            // find GIT exe file
                            //if (!System.IO.File.Exists(HttpContext.Session.GetString(Session.GIT) + @"\sh.exe"))
                            //{
                            //    isLoggedIn = false;
                            //    // maybe throw an error
                            //}

                            // Need this to set stating organization name
                            //Classes.VSTS.Vsts.SetOrg(_settings.Setting.GetSection("Organization").Value);
                            //var tempVsts = new Classes.VSTS.Vsts(HttpContext.Session.GetString(Session.TOKEN));
                            //var projects = tempVsts.GetProjects();


                            //if (projects != null)
                            //    HttpContext.Session.SetComplexData(Session.PROJECTS, projects);
                        }
                        catch (System.Exception ex)
                        {
                            System.Diagnostics.Debug.WriteLine(ex.Message);
                            isLoggedIn = false;
                        }

                        HttpContext.Session.SetInt32(Session.LOGGEDIN, isLoggedIn ? 0 : 1);
                    }
                    return(RedirectToAction("Index", "Home"));
                }
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 7
0
 public ActionResult Login()
 {
     Models.LoginVM login = new Models.LoginVM();
     return(View(login));
 }
 public ActionResult Login()
 {
     Models.LoginVM vm = new Models.LoginVM();
     return(View(vm));
 }