Exemplo n.º 1
0
        /// <summary>
        /// Perform the necessary action to update the module's state, and
        /// send the email to the module submitter if emails are enabled.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SendBtn_Click(object sender, System.EventArgs e)
        {
            Emails.formatEmailBody(Message, CustomMessage.Text);
            MailMessage msg = Emails.constructMailMessage(Message, UserName, Globals.EditorsEmail);

            switch (Message.Type)
            {
            case EmailType.SubmitterApproved:
                UsersControl.approveSubmitter(UserName);
                break;

            case EmailType.SubmitterDenied:
                UsersControl.rejectSubmitter(UserName);
                break;

            case EmailType.ModuleApproved:
                ModulesControl.approveModule(ModuleID);
                break;

            case EmailType.ModuleDeniedSave:
                ModulesControl.rejectModule(ModuleID, true);
                break;

            case EmailType.ModuleDeniedDelete:
                ModulesControl.rejectModule(ModuleID, false);
                deleteMaterials();
                break;

            case EmailType.FacultyApproved:
                UsersControl.approveFaculty(UserName);
                break;

            case EmailType.FacultyDenied:
                UsersControl.rejectFaculty(UserName);
                break;
            }

            // Message to be displayed on editors page.
            string successMessage = "Operation successful.  ";

            // Only send an email if they're enabled.
            if (Globals.EmailsEnabled)
            {
                try {
                    SmtpMail.SmtpServer = AspNetForums.Components.Globals.SmtpServer;
                    SmtpMail.Send(msg);
                    successMessage += "Email sent to user.";
                } catch (Exception ex) {
                    successMessage += "But an error occurred while sending an email to the user.";
                }
            }
            else
            {
                successMessage += "Email not sent to user because they are disabled.";
            }

            Response.Redirect("EditorsPage.aspx?message=" +
                              HttpUtility.UrlEncode(successMessage));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Handles the 'Yes' button click event.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void YesButton_Click(object sender, System.EventArgs e)
 {
     // If the user clicked Yes, update their user account to "Canceled"
     // and redirect them to the default page.
     UserAccounts.UserInfo user = UserAccounts.getUserInfo(User.Identity.Name);
     user.Role = UserRole.Canceled;
     // Updates the user's role and sends them an email telling them
     // about the change.
     UsersControl.updateUserRole(user);
     UsersControl.logoutUser();
     Response.Redirect("default.aspx", true);
 }
        protected void SelectionChanged(object source, System.EventArgs e)
        {
            // Get a reference to the DropDownList;
            DropDownList ddl = (DropDownList)source;
            DataGridItem dgi = (DataGridItem)ddl.Parent.Parent;

            UserAccounts.UserInfo user = new UserAccounts.UserInfo();
            user.Username = ((HyperLink)dgi.Cells[0].FindControl("UserLink")).Text;
            user.Role     = (UserRole)(Convert.ToInt32(ddl.SelectedValue));
            UsersControl.updateUserRole(user);
            bindGrid();
        }
Exemplo n.º 4
0
 /// <summary>
 /// Handles the Submit button-click events.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Submit_Click(object sender, System.EventArgs e)
 {
     try {
         if (EditUserInfoControl1.Page.IsValid)
         {
             UsersControl.updateUser(EditUserInfoControl1.UserInfo);
             Response.Redirect("MyAccount.aspx?message=User information updated successfully.", true);
         }
     } catch (Exception ex) {
         ErrorMessage.Text = ex.Message;
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Handles Login button-click events.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LoginBtn_Click(object sender, System.EventArgs e)
        {
            bool passwordVerified = false;

            try {
                // Verify password and set authorization cookie, if valid.
                passwordVerified =
                    UserAccounts.VerifyPassword(txtUserName.Text, txtPassword.Text);
                UserAccounts.UserInfo user = UserAccounts.getUserInfo(txtUserName.Text);

                if (!passwordVerified)
                {
                    // First, see if the username exists and if the password
                    // is correct.  If the username doesn't exist, or if
                    // the password is incorrect, reset the fields and notify
                    // user of the problem.
                    lblMessage.Text  = "Invalid username or password.";
                    txtUserName.Text = "";
                    txtPassword.Text = "";
                }
                else if (user.Role == UserRole.Disabled)
                {
                    // If the username exists and the password was correct,
                    // check to see if the account has been disabled.  If so,
                    // notify the user and reset the fields.
                    lblMessage.Text  = "That account has been disabled.";
                    txtUserName.Text = "";
                    txtPassword.Text = "";
                }
                else
                {
                    // Keep track of redirection information
                    string url = Request.QueryString["ReturnUrl"] == null ? "MyAccount.aspx" :
                                 FormsAuthentication.GetRedirectUrl(txtUserName.Text, false);

                    if (user.Role == UserRole.Canceled)
                    {
                        // If this account had been Canceled, reset them to User status,
                        // and redirect them to a page with the appropriate information.
                        user.Role = UserRole.User;
                        UsersControl.updateUserRole(user);
                        Session["CancelType"] = "Reactivate";
                        url = "AccountCanceled.aspx?ReturnUrl=" + url;
                    }

                    Response.Redirect(url);
                }
            } catch (Exception ex) {
                lblMessage.Text = ex.Message;
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Handles Register button-click events
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RegisterBtn_Click(object sender, System.EventArgs e)
        {
            Page.Validate();

            if (Page.IsValid)
            {
                UserAccounts.UserInfo ui = EditUserInfoControl1.UserInfo;

                try {
                    UsersControl.registerUser(ui);
                    FormsAuthentication.RedirectFromLoginPage(ui.Username, false);
                } catch (Exception ex) {
                    lblMessage.Text = "<p>Error registering user.  " + ex.Message + "</p>";
                }
            }
        }
Exemplo n.º 7
0
        private void SubmitBtn_Click(object sender, System.EventArgs e)
        {
            // Try to retrieve user information with the given username
            UserAccounts.UserInfo user = UserAccounts.getUserInfo(txtUserName.Text);

            // Check if the user actually exists
            if (user == null)
            {
                lblMessage.Text = "Username not found.";
            }
            else
            {
                int index = secretQuestion.getQuestionID();

                // Check that the secret question and answer were right
                if (user.QuestionID != index || user.QuestionAnswer != secretQuestion.getAnswer())
                {
                    lblMessage.Text = "Some or all of the data you entered was "
                                      + "incorrect.  Please revise your answers and try again.  ";
                }
                else
                {
                    // generate a password
                    string newPwd = generatePassword();

                    // set the password in the database
                    user.Password = newPwd;
                    UsersControl.updateUser(user);

                    // send it to their email
                    Email email = Emails.getEmail(EmailType.PasswordReset);
                    Emails.formatEmail(email, user.Username, newPwd);
                    MailMessage msg = Emails.constructMailMessage(email, user.Username, Globals.AdminsEmail);
                    SmtpMail.SmtpServer = AspNetForums.Components.Globals.SmtpServer;
                    SmtpMail.Send(msg);

                    // give them further instructions and set the visibility
                    // of the command buttons accordingly
                    lblMessage.Text = "An email has been sent to: " + user.Email
                                      + ".  Please check your email for your new password.  "
                                      + "You may change this password after you log in.  "
                                      + "Click Continue to go to the login page.  ";
                    SubmitBtn.Visible   = false;
                    ContinueBtn.Visible = true;
                }
            }
        }