Beispiel #1
0
        private ClientUserInfo GenerateClientUserInfo(string userName)
        {
            using (var context = new GSLogisticsContext())
            {
                var userInfo = new ClientUserInfo();
                var user     = context.UserInfos.Where(x => x.UserName == userName).FirstOrDefault();

                if (user != null)
                {
                    userInfo.UserName = user.UserName;

                    if (user.UserCustomers != null && user.UserCustomers.Any())
                    {
                        List <string> clientIds   = new List <string>();
                        List <int>    divisionIds = new List <int>();

                        clientIds   = user.UserCustomers.Select(x => x.CustomerId).Distinct().ToList();
                        divisionIds = user.UserCustomers.Select(x => x.DivisionId).Distinct().ToList();

                        userInfo.CustomerIds = clientIds.ToArray();
                        userInfo.DivisionIds = divisionIds.ToArray();
                    }
                }
                return(userInfo);
            }
        }
Beispiel #2
0
        public static ClientUserInfo Login(ClientUserInfo userInfor)
        {
            try
            {
                var endPointString = endPointQLBH + "api/accounts/login";
                var nguoidung      = Task.Run(() => PostAsync <ClientUserInfo>(endPointString, userInfor)).Result;

                return(nguoidung);
            }
            catch (BusinessLayerException)
            {
                throw new BusinessLayerException(500, "Đăng nhập thất bại.");
            }
            catch (Exception)
            {
                throw new BusinessLayerException(500, "Đăng nhập thất bại.");
            }
        }
        public ActionResult UpdateProfile(ClientUserInfo ui)
        {
            if (!ModelState.IsValid)
            {
                // TODO: Captcha validation failed, show error message
                ViewBag.ErrorMsg = "Incorrect CAPTCHA code!";
            }
            else
            {
                ClientUser u = ui.FullInfo;
                u.f_Password = Ulti.Md5Hash(ui.Password);

                CSDLQLBH.UpdateUser(u.f_ID, u);

                Session["Updated"] = 1;
                Session["Logged"]  = null;
                Session["cart"]    = null;
                Response.Cookies["UserId"].Expires = DateTime.Now.AddDays(-1);
                return(RedirectToAction("Login", "Account"));
            }
            return(View());
        }
        public ActionResult Login(ClientUserInfo ui)
        {
            var pass = Ulti.Md5Hash(ui.Password);
            var user = CSDLQLBH.Login(ui);

            if (user != null)
            {
                if (user.Permission == "Customer")
                {
                    Session["Logged"]  = ui;
                    Session["Updated"] = null;
                    Response.Cookies["UserId"].Value   = user.FullInfo.f_ID.ToString();
                    Response.Cookies["UserId"].Expires = DateTime.Now.AddDays(7);

                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    //them chuc nang admin
                    ui.Permission = user.Permission;
                    //cookie
                    Session["Logged"]  = ui;
                    Session["Updated"] = null;
                    Response.Cookies["UserId"].Value   = user.FullInfo.f_ID.ToString();
                    Response.Cookies["UserId"].Expires = DateTime.Now.AddDays(7);

                    return(RedirectToAction("Index", "ManageProduct"));// trả về trang Index nếu đã nhập đúng thông tin
                }
            }


            else
            {
                ViewBag.ErrorMsg = "Thông tin đăng nhập chưa đúng";
            }

            return(View());
        }
Beispiel #5
0
        /// <summary>
        /// Login
        /// </summary>
        /// <param name="username"></param>
        /// <param name="pswd"></param>
        private void DoLogin(string username, string pswd, bool persist)
        {
            string errMsg   = string.Empty;
            string strWhere = " EmailAddress='" + username + "'";
            List <eChartProject.Model.eChart.fund> user = FundBll.GetModelList(strWhere);


            if (user != null && user.Count > 0)
            {
                ClientUserInfo clientUserInfo = new ClientUserInfo();
                clientUserInfo.Email  = user[0].EmailAddress;
                clientUserInfo.FundID = user[0].ID;

                strWhere = " FundID=" + clientUserInfo.FundID + " and isclientadded=0  and FundBankAccountNo = '" + pswd + "'";
                List <eChartProject.Model.eChart.fundbankaccount> fundbank = FundBankAccountBll.GetModelList(strWhere);

                if (fundbank != null && fundbank.Count > 0)
                {
                    SessionInfo.ClientUserInfo = clientUserInfo;

                    FormsAuthentication.SetAuthCookie(clientUserInfo.FundID.ToString(), persist);
                    Response.Write("success");
                    Response.End();
                }
                else
                {
                    errMsg = "The email or the password is invalid.";
                    Response.Write(errMsg);
                    Response.End();
                }
            }
            else
            {
                errMsg = "The email or the password is invalid.";
                Response.Write(errMsg);
                Response.End();
            }
        }
Beispiel #6
0
        /// <summary>
        /// Get Client Users
        /// </summary>
        /// <param name="uId">UID</param>
        /// <returns>Client Users</returns>
        public List <ClientUserInfo> GetClientUsers(String uId)
        {
            SqlParameter[] parms = { new SqlParameter("@UID", SqlDbType.VarChar, 20) };
            parms[0].Value = uId;

            var users = new List <ClientUserInfo>();

            using (var rdr = SQLHelper.ExecuteReader(SQLHelper.ConnectionStringLocalTransaction, CommandType.Text, SQLText.SQL_MS_GetClientUsers, parms)) {
                while (rdr.Read())
                {
                    var user = new ClientUserInfo();
                    user.ID         = ComUtility.DBNullInt32Handler(rdr["ID"]);
                    user.ClientName = ComUtility.DBNullStringHandler(rdr["ClientName"]);
                    user.UID        = ComUtility.DBNullStringHandler(rdr["UID"]);
                    user.Pwd        = ComUtility.DBNullStringHandler(rdr["PWD"]);
                    user.OpLevel    = ComUtility.DBNullInt32Handler(rdr["OpLevel"]);
                    user.PortVer    = ComUtility.DBNullInt32Handler(rdr["PortVer"]);
                    user.Enabled    = ComUtility.DBNullBooleanHandler(rdr["Enabled"]);
                    users.Add(user);
                }
            }
            return(users);
        }
Beispiel #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //display the Supporter's info
            eChartProject.BLL.eChart.accounts_users bll = new eChartProject.BLL.eChart.accounts_users();
            string strWhere = " 1=1 order by UserID desc";
            List <eChartProject.Model.eChart.accounts_users> user = bll.GetModelList(strWhere);

            if (user != null && user.Count > 0)
            {
                UserInfo userInfo = new UserInfo();
                userInfo.Email      = user[0].Email;
                userInfo.Password   = user[0].Password;
                userInfo.UserId     = user[0].UserID;
                userInfo.Age        = (int)user[0].Age;
                userInfo.City       = user[0].City;
                userInfo.Country    = user[0].Country;
                userInfo.UserName   = user[0].Username;
                userInfo.UserStatus = (int)user[0].UserStatus;

                SessionInfo.UserInfo = userInfo;

                this.txtName.Value    = userInfo.UserName;
                this.txtGender.Value  = userInfo.Gender == "true"?"F":"M";
                this.txtCountry.Value = userInfo.Country;
                this.txtCity.Value    = userInfo.City;
                this.txtAge.Value     = userInfo.Age.ToString() + " yrs";
                TextName.InnerText    = userInfo.UserName;
            }
            //GET CLIENT USER'S COOKIE INFORMATION
            string     cookieName = FormsAuthentication.FormsCookieName;
            HttpCookie authCookie = Context.Request.Cookies[cookieName];

            if (authCookie != null)
            {
                FormsAuthenticationTicket authTicket = null;

                authTicket = FormsAuthentication.Decrypt(authCookie.Value);

                FormsIdentity identity = new FormsIdentity(authTicket);

                string fundID = identity.Name;
                int    outresult;
                if (int.TryParse(fundID, out outresult))
                {
                    strWhere = " ID=" + fundID;
                    List <eChartProject.Model.eChart.fund> user2 = FundBll.GetModelList(strWhere);


                    if (user != null && user.Count > 0)
                    {
                        ClientUserInfo clientUserInfo = new ClientUserInfo();
                        clientUserInfo.Email  = user2[0].EmailAddress;
                        clientUserInfo.FundID = user2[0].ID;

                        strWhere = " FundID=" + clientUserInfo.FundID + " and isclientadded=0  ";
                        List <eChartProject.Model.eChart.fundbankaccount> fundbank = FundBankAccountBll.GetModelList(strWhere);

                        if (fundbank != null && fundbank.Count > 0)
                        {
                            clientUserInfo.Pswd        = fundbank[0].FundBankAccountNo;
                            SessionInfo.ClientUserInfo = clientUserInfo;

                            txtEmail.Value = clientUserInfo.Email;
                            txtPassword.Attributes.Add("value ", clientUserInfo.Pswd);
                            btnLogin.Style["display"]   = "none";
                            ddRemember.Style["display"] = "none";

                            lbtnLogout.Style["display"]        = "inline";
                            ValidationSummary.Style["display"] = "none";
                            PrivateValidation.Style["display"] = "inline";
                        }
                        else
                        {
                            lbtnLogout.Style["display"] = "none";
                        }
                    }
                    else
                    {
                        lbtnLogout.Style["display"] = "none";
                    }
                }
                else
                {
                    lbtnLogout.Style["display"] = "none";
                }
            }
            else
            {
                lbtnLogout.Style["display"] = "none";
            }

            InitializeLearnMORE();
        }