Beispiel #1
0
        private static List <int> getUserPrivilegeIds(object userIdObj)
        {
            int                       userId                    = (int)userIdObj;
            AuthenService             authenService             = new AuthenService();
            UserPrivilegeTableAdapter userPrivilegeTableAdapter = (UserPrivilegeTableAdapter)StaticDataFacade.Get(StaticDataKeys.AdapterUserPrivilege);
            UserPrivilegeDataTable    userPrivilegeDataTable    = authenService.LoadUserPrivileges(userPrivilegeTableAdapter, userId);
            List <int>                privilegeIds              = new List <int>();

            foreach (UserPrivilegeRow row in userPrivilegeDataTable)
            {
                privilegeIds.Add(row.PrivilegeId);
            }

            return(privilegeIds);
        }
Beispiel #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            AuthenService authenService = new AuthenService();
            string        username      = txtUsername.Text;
            string        password      = PasswordUtil.GetMd5Hash(txtPassword.Text);
            UserDataTable userDataTable = authenService.GetUsersForLogin(this.userTableAdapter, username, password);

            if (userDataTable.Count == 0)
            {
                MessageBox.Show("Tên đăng nhập hoặc Mật khẩu không đúng. Xin vui lòng thử lại.", "Lỗi đăng nhập",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                UserPrivilegeDataTable upTable = authenService.LoadUserPrivileges(this.userPrivilegeTableAdapter, userDataTable[0].UserId);
                authenService.SetAuthenticatedUser(userDataTable[0], upTable);
                this.Close();

                showCurrentForm();
            }
        }