public AmscoUser AuthenticateUser(string id, string password) { AmscoUser user = new AmscoUser("", "", "", false); UsersDataSet usersDataSet = this.GetUsers(); IEnumerator en = usersDataSet.Users.GetEnumerator(); while (en.MoveNext()) { DataRow dataRow = (DataRow)en.Current; string userId = (string)dataRow.ItemArray[UsersDataAccess.USER_ID_INDEX]; string userPassword = (string)dataRow[UsersDataAccess.USER_PASSWORD_INDEX]; if (id.Equals(userId) && password.Equals(userPassword)) { string userRole = (string)dataRow[UsersDataAccess.USER_ROLE_INDEX]; user = new AmscoUser(userId, userPassword, userRole, true); break; } } return(user); }
protected void loginButton_Click(object sender, EventArgs e) { Session.Clear(); if (this.userIdTextBox.Text.Trim().Equals("")) { this.messageLabel.Text = "Please specify a user name!"; } else if (this.userPasswordTextBox.Text.Trim().Equals("")) { this.messageLabel.Text = "Please specify a password!"; } else { UsersDataAccess usersDataAccess = new UsersDataAccess(); string id = this.userIdTextBox.Text; string pwd = this.userPasswordTextBox.Text; AmscoUser user = usersDataAccess.AuthenticateUser(id, pwd); if (user.IsAuthenticated) { if (user.Role.Equals("Beta Tester")) { Session["UserId"] = user.Id; Session["UserRole"] = user.Role; Response.Redirect("~/Beta/BetaMain.aspx"); } else { this.messageLabel.Text = "You are not authorized!"; } } else { this.messageLabel.Text = "You are not authenticated!"; } } }