示例#1
0
        private void BindData()
        {
            DataTable dtUsers = new d.CmsUserData().GetAllUsersByRole(getRoleId());

            cblUsers.DataSource     = dtUsers;
            cblUsers.DataTextField  = "Displayed";
            cblUsers.DataValueField = "Id";
            cblUsers.DataCheckField = "Selected";
            cblUsers.DataBind();
        }
示例#2
0
        protected override int SaveItem()
        {
            int cmsUserId = new d.CmsUserData().Create(
                tbxEmail.Text.Trim(), generatePassword(8), tbxFirstName.Text.Trim(), "", tbxLastName.Text.Trim(), Identity.UserId);

            if (cmsUserId < 0)
            {
                valUnique.IsValid = false;
                return(0);
            }
            return(1);
        }
示例#3
0
        private void BindData()
        {
            DataTable dtUsers = new d.CmsUserData().GetArchivedUsers(dgrUsers.SortExpression);

            if (dtUsers.Rows.Count > 0)
            {
                pnlGrid.Visible     = true;
                dgrUsers.Prefix     = LinkPrefix;
                dgrUsers.DataSource = dtUsers;
                dgrUsers.DataBind();
            }
            else
            {
                pnlGrid.Visible = false;
            }
        }
示例#4
0
        private void btnLogin_Click(object sender, System.EventArgs e)
        {
            d.CmsUserData cud       = new d.CmsUserData();
            int           cmsuserId = cud.ValidateUser(tbxLogin.Text, tbxPassword.Text);

            if (cmsuserId > 0)
            {
                d.CmsUser user        = new d.CmsUser(cmsuserId);
                ArrayList permList    = cud.GetPermissionCodesByUser(cmsuserId);
                string    permissions = "";
                for (int i = 0; i < permList.Count; i++)
                {
                    permissions += permList[i] + "|";
                }

                if (permissions.Length > 0)
                {
                    permissions = permissions.Substring(0, permissions.Length - 1); //gets rid of last delimeter
                }
                FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(
                    1,
                    cmsuserId.ToString(),
                    DateTime.Now,
                    DateTime.Now.AddMinutes(20),
                    false,
                    permissions);  //version + userid + creation + expiration + persistent + user permissions(codes)

                string     encryptedTicket = FormsAuthentication.Encrypt(authTicket);
                HttpCookie authCookie      = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
                string     infoCookieName  = b.ConfigurationHelper.InfoCookieName;
                HttpCookie infoCookie      = new HttpCookie(infoCookieName);
                infoCookie.Values["Login"]     = user.Login;
                infoCookie.Values["FirstName"] = user.FirstName;
                infoCookie.Values["LastName"]  = user.LastName;
                Response.Cookies.Add(authCookie);
                Response.Cookies.Add(infoCookie);

                string redirect = FormsAuthentication.GetRedirectUrl(tbxLogin.Text, false);
                Response.Redirect(redirect);
            }
            else
            {
                lblAuthFailure.Text    = "Login failed for " + tbxLogin.Text;
                lblAuthFailure.Visible = true;
                tbxLogin.Text          = string.Empty;
            }
        }