コード例 #1
0
ファイル: MainForm.cs プロジェクト: markic/DMS
        private void LoadUserDetails(UserDTO userDto)
        {
            editUserPanel.Visible           = true;
            panelUserSearch.Visible         = false;
            usersGrid.Visible               = false;
            btnAddNewUser.Visible           = false;
            btnResetPassword.Visible        = false;
            tbUserDetailsUserName.ReadOnly  = false;
            tbUserDetailsUserName.BackColor = Color.White;
            _hiddenUserDetailsId            = 0;
            _formsService.ResetFormTextBoxes(editUserPanel.Controls);
            selectUserRole.Text = Enum.GetName(typeof(AuthorizationRoleCodes), _defaultRole);

            if (userDto != null)
            {
                tbUserDetailsContactPhone.Text  = userDto.ContactPhone;
                tbUserDetailsEmail.Text         = userDto.Email;
                tbUserDetailsFirstName.Text     = userDto.FirstName;
                tbUserDetailsLastName.Text      = userDto.LastName;
                tbUserDetailsOfficeNumber.Text  = userDto.OfficeNumber;
                tbUserDetailsTitle.Text         = userDto.Title;
                tbUserDetailsUserName.Text      = userDto.UserName;
                tbUserDetailsUserName.ReadOnly  = true;
                tbUserDetailsUserName.BackColor = Color.LightGray;
                selectUserRole.Text             = Enum.GetName(typeof(AuthorizationRoleCodes), userDto.AuthorizationRole);
                btnResetPassword.Visible        = true;
                _hiddenUserDetailsId            = userDto.Id;
            }
        }
コード例 #2
0
ファイル: NewPasswordForm.cs プロジェクト: markic/DMS
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(this.passwordTextBox1.Text) || String.IsNullOrEmpty(this.passwordTextBox2.Text))
            {
                return;
            }
            if (!this.passwordTextBox1.Text.Equals(this.passwordTextBox2.Text))
            {
                return;
            }
            if (this.passwordTextBox1.Text.Length < AuthorizationBusinessService.PASSWORD_CHAR_MIN)
            {
                return;
            }

            this.lblError.Text = String.Empty;

            LoginForm loginForm = (LoginForm)_formsService.GetFormByCode(FormTypeCodes.LoginForm);

            string   hash     = new AuthorizationBusinessService().HashPassword(this.passwordTextBox1.Text);
            MainForm mainForm = (MainForm)_formsService.GetFormByCode(FormTypeCodes.MainForm);

            mainForm.loggedUser = _formsService.UsersService.SaveUserPassword(loginForm.GetUserName.Text, hash);

            _formsService.ResetFormTextBoxes(this.Controls);
            _formsService.ActivateForm(FormTypeCodes.MainForm);
            _formsService.ResetFormTextBoxes(loginForm.Controls);
        }
コード例 #3
0
ファイル: LoginForm.cs プロジェクト: markic/DMS
        private void TryToLogin()
        {
            try
            {
                if (String.IsNullOrEmpty(this.UserName.Text))
                {
                    return;
                }

                _user = _formsService.UsersService.LoadUserByName(this.UserName.Text);

                if (_user.HasEmptyPassword && this.Password.Text.Equals(""))
                {
                    _formsService.ActivateForm(FormTypeCodes.NewPasswordForm);
                    this.lblError.Text = String.Empty;
                    return;
                }

                if (String.IsNullOrEmpty(this.Password.Text))
                {
                    this.lblError.Text = String.Format("Morate uneti lozinku.");
                    return;
                }

                string inputHash = _authorizationService.HashPassword(this.Password.Text);

                if (inputHash.Equals(_user.PasswordHash))
                {
                    MainForm mainForm = (MainForm)_formsService.GetFormByCode(FormTypeCodes.MainForm);
                    mainForm.loggedUser = _user;
                    _formsService.ActivateForm(FormTypeCodes.MainForm);

                    _formsService.ResetFormTextBoxes(this.Controls);
                    this.lblError.Text = String.Empty;
                    return;
                }

                this.lblError.Text = String.Format("Uneta lozinka nije ispravna.");
            }
            catch (UserNotFoundException ex)
            {
                this.lblError.Text = String.Format("{0}'{1}'.", ex.Message, this.UserName.Text);
            }
            catch (Exception ex)
            {
                BusinessServiceBase.logger.Error(ex);
                this.lblError.Text = "Došlo je do sistemske greške. Kontaktirajte administratora.";
            }
        }
コード例 #4
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     lblError.Text = String.Empty;
     _formsService.ResetFormTextBoxes(this.Controls);
     _formsService.ActivateForm(FormTypeCodes.LoginForm);
 }