示例#1
0
        protected void OnSave(object sender, EventArgs args)
        {
            try
            {
                string pwd = "";
                if (txtPassword.Text != "")
                {
                    if (txtPassword.Text != txtPassword2.Text)
                    {
                        msg.Error = Portal.API.Language.GetText(this, "InvalidPassword");
                        return;
                    }
                    pwd = txtPassword.Text;
                }
                Portal.API.Principal principal = (Portal.API.Principal)Page.User;
                UserManagement.SaveUser(
                    Page.User.Identity.Name,
                    pwd, txtFirstName.Text, txtSurName.Text, txtEMail.Text,
                    new System.Collections.ArrayList(principal.Roles), principal.Id);
                msg.Success = Portal.API.Language.GetText(this, "SuccessfullySaved");

                HttpContext.Current.User = UserManagement.GetUser(principal.Login);

                Bind();
            }
            catch (Exception e)
            {
                msg.Error = e.Message;
            }
        }
示例#2
0
        /// <summary>
        /// Returns an Identityobject for the given account
        /// </summary>
        /// <param name="account">User Account/Login</param>
        /// <returns>Identity</returns>
        public static Portal.API.Principal GetUser(string account)
        {
            if (null == account)
            {
                throw new ArgumentException(Language.GetText("exception_NullReferenceParameter"), "account");
            }

            Users u = Users;

            Users.UserRow user = u.User.FindBylogin(account.ToLower(CultureInfo.CurrentCulture));
            if (user == null)
            {
                return(null);
            }

            IIdentity UsrIdentity = new GenericIdentity(user.login, HttpContext.Current.User.Identity.AuthenticationType);

            Portal.API.Principal UsrPrincipal = new Portal.API.Principal(UsrIdentity, GetRoles(account));
            UsrPrincipal.Id        = user.id;
            UsrPrincipal.FirstName = user.IsfirstNameNull() ? "" : user.firstName;
            UsrPrincipal.SurName   = user.IssurNameNull() ? "" : user.surName;
            UsrPrincipal.EMail     = user.IsemailNull() ? "" : user.email;

            return(UsrPrincipal);
        }
示例#3
0
        private void Bind()
        {
            Portal.API.Principal principal = (Portal.API.Principal)Page.User;

            txtLogin.Text     = principal.Login;
            txtPassword.Text  = "";
            txtPassword2.Text = "";
            txtFirstName.Text = HttpUtility.HtmlDecode(principal.FirstName);
            txtSurName.Text   = HttpUtility.HtmlDecode(principal.SurName);
            txtEMail.Text     = HttpUtility.HtmlDecode(principal.EMail);
        }
		/// <summary>
		/// Returns an Identityobject for the given account
		/// </summary>
		/// <param name="account">User Account/Login</param>
		/// <returns>Identity</returns>
		public static Portal.API.Principal GetUser(string account)
		{
            if (null == account)
                throw new ArgumentException(Language.GetText("exception_NullReferenceParameter"), "account");
            
            Users u = Users;

			Users.UserRow user = u.User.FindBylogin(account.ToLower(CultureInfo.CurrentCulture));
			if(user == null) return null;

			IIdentity UsrIdentity = new GenericIdentity(user.login, HttpContext.Current.User.Identity.AuthenticationType);
      Portal.API.Principal UsrPrincipal = new Portal.API.Principal(UsrIdentity, GetRoles(account));
      UsrPrincipal.Id = user.id;
      UsrPrincipal.FirstName = user.IsfirstNameNull() ? "" : user.firstName;
      UsrPrincipal.SurName = user.IssurNameNull() ? "" : user.surName;
      UsrPrincipal.EMail = user.IsemailNull() ? "" : user.email;

      return UsrPrincipal;
		}