Example #1
0
 private void BindData()
 {
     d.CmsUser user = new d.CmsUser(GetId());
     tbxEmail.Text         = user.Login;
     tbxFirstName.Text     = user.FirstName;
     tbxLastName.Text      = user.LastName;
     tbxDisplayedName.Text = user.DisplayedName;
 }
Example #2
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;
            }
        }
Example #3
0
        protected override int SaveItem()
        {
            d.CmsUser user = new d.CmsUser(GetId());
            if (tbxPassword.Text.Trim() != "")
            {
                user.Password = tbxPassword.Text.Trim();
            }
            user.Login         = tbxEmail.Text.Trim();
            user.FirstName     = tbxFirstName.Text.Trim();
            user.LastName      = tbxLastName.Text.Trim();
            user.DisplayedName = tbxDisplayedName.Text.Trim();

            if (user.Update() < 0)
            {
                valUnique.IsValid = false;
                return(0);
            }
            return(1);
        }