Ejemplo n.º 1
0
 protected void submit_Click(object sender, EventArgs e)
 {
     if (!String.IsNullOrEmpty(this.userId.Text))
     {
         CMNUserDataSet userDS = _bc.getUserByLoginID(this.userId.Text);
         if (userDS.T_CMN001_USER != null && userDS.T_CMN001_USER.Count > 0)
         {
             string password = CryptionUtil.DecryptAESSecruedMsg(userDS.T_CMN001_USER[0].PASSWORD_HASH, this.userId.Text, userDS.T_CMN001_USER[0].PASSWORD_HASH_SALT);
             if (password.Equals(this.password.Text))
             {
                 ProcessAuthentication(this.userId.Text, userDS.T_CMN001_USER[0].COMPANY_ID, "C", userDS.T_CMN001_USER[0].USER_ROLE_ARR, this.userId.Text, "", "");
             }
         }
     }
 }
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            if (IsValid && !String.IsNullOrEmpty(this.userName.Text) && pass1.Text.Equals(pass2.Text))
            {
                bool exists = checkExistsUser();

                if (!exists)
                {
                    //ProcessAuthentication(userId
                    CMNUserDataSet userDS = new CMNUserDataSet();
                    CMNUserDataSet.T_CMN001_USERRow userRow = userDS.T_CMN001_USER.NewT_CMN001_USERRow();
                    userRow.USERID        = Utility.NewDataKey();
                    userRow.LOGINID       = this.userName.Text;
                    userRow.USER_NAME     = this.displayName.Text;
                    userRow.EMAIL_ADDRESS = this.email.Text;
                    userRow.STATUS        = Constants.UserStatus.ACTIVE;
                    userRow.USER_ROLE_ARR = Constants.UserRoles.PROCESS_ROLE;
                    userRow.COMPANY_ID    = "-1";// default company

                    Utility.UpdateCommonFields(userRow);
                    userDS.T_CMN001_USER.AddT_CMN001_USERRow(userRow);

                    byte[] saltBytes    = CryptionUtil.GeneratorSalt(this.userName.Text);
                    byte[] encryptedMsg = CryptionUtil.EncryptAESSecruedMsg(pass1.Text, userName.Text, saltBytes);

                    userRow.PASSWORD_HASH      = encryptedMsg;
                    userRow.PASSWORD_HASH_SALT = saltBytes;

                    _bc.SaveUser(userDS);
                    //this.msgTxt.Text = "Successful!";

                    Response.Redirect("~/Public/Login/Login.aspx");
                }
                else
                {
                    ShowMessage("The User Name is already registered, Please using another one and retry.", MessageSeverity.Error);
                }
            }
        }