Esempio n. 1
0
        public ActionResult Profile()
        {
            if (Session["EmployeeLogin"] == null)
            {
                return(Redirect("/User/Login?returnUrl=/User/Profile"));
            }
            NI10_Employee employee = (Session["EmployeeLogin"] != null) ? (NI10_Employee)Session["EmployeeLogin"] : new NI10_Employee();

            employee         = new SqlNI10_EmployeeDao().GetSingleByCustomDataSource(new object[] { "@employeeCode", employee.EmployeeCode }, "[dbo].[NI10_Employee_GetEmployeeInfo]");
            ViewBag.UserInfo = employee;
            return(View());
        }
Esempio n. 2
0
        public ActionResult Login(LoginModel model)
        {
            string        result = "", actiontype = "";
            NI10_Employee employee = new SqlNI10_EmployeeDao().GetSingleByCustomDataSource(new object[] { "@employeeCode", model.LoginName }, "[dbo].[NI10_Employee_GetEmployeeInfo]");

            if (employee != null)
            {
                if (isADAuthenticate)
                {
                    if (ValidateUserLDAP(model.LoginName, model.PassWord.Trim()) == false)
                    {
                        UserPrincipal userPrincipal = LdapFunction.GetUserPrincipal(model.LoginName);
                        if (userPrincipal != null)
                        {
                            if (userPrincipal.AccountExpirationDate != null)
                            {
                                actiontype = "1";
                                result     = "Tài khoản đã nghỉ việc. Vui lòng liên hệ support để hỗ trợ";
                            }
                            else if (userPrincipal.AccountLockoutTime != null)
                            {
                                actiontype = "1";
                                result     = "Tài khoản của bạn đã bị khóa. Vui lòng liên hệ support để hỗ trợ";
                                Session["countLoginFail"] = "0";
                            }
                            else
                            {
                                result     = "Username hoặc password không đúng. Vui lòng kiểm tra lại";
                                actiontype = "1";
                            }
                        }
                        TempData["error"] = result;
                    }
                    else
                    {
                        actiontype = "0";
                        this.FillLoginInfo(employee.JobTitle, model.LoginName.Trim(), employee.FullName, employee.EmployeeCode, "", false, "", "", employee.Avatar, "false", 0, StaticFunc.EncryptIntranet(model.PassWord.Trim()), employee.EmailAddress);
                        if (model.ReturnUrl == null)
                        {
                            return(Redirect("/TankList/Home"));
                        }
                        return(Redirect(model.ReturnUrl));
                    }
                }
            }
            return(View());
        }