//---------------------------------------------------------------------------------------//
        protected void btnSubmit_Click(object sender, System.EventArgs e)
        {
            string userName = txtUsername.Text.Trim();
            string email = txtEmail.Text.Trim();

            string prompt = "Please enter ";
            string errorMessage = null;
            if (userName.Length == 0)
            {
                errorMessage = prompt + "Username";
            }
            else if (email.Length == 0)
            {
                errorMessage = prompt + "Email Address";
            }
            if (errorMessage != null)
            {
                lblResponse.Text = Utilities.FormatErrorMessage(errorMessage);
                lblResponse.Visible = true;
                return;
            }

            AuthorizationWrapperClass wrapper = new AuthorizationWrapperClass();
            int userID = wrapper.GetUserIDWrapper(userName);
            if (userID < 0)
            {
                // userID does not exist in the database
                lblResponse.Text = Utilities.FormatErrorMessage("This username does not exist.");
                lblResponse.Visible = true;
                return;
            }

            User[] lostPassUsers = wrapper.GetUsersWrapper(new int[] { userID });

            if (lostPassUsers[0].userID == 0)
            {
                // userID does not exist in the database
                lblResponse.Text = Utilities.FormatErrorMessage("This username does not exist.");
                lblResponse.Visible = true;
            }
            else if (email.ToLower() != wrapper.GetUsersWrapper(new int[] { userID })[0].email.ToLower())
            {
                // email does not match email record in our database
                lblResponse.Text = Utilities.FormatErrorMessage("Please use the username AND email you were registered with.");
                lblResponse.Visible = true;
            }
            else // send password to requestor's email address
            {
                //
                // Email new password to user
                //
                string subject = "[" + this.serviceBrokerName + "] Lost Password";

                StringWriter message = new StringWriter();
                message.WriteLine("Username: "******"Email:    " + email);
                message.WriteLine();
                message.WriteLine("Your old password has been reset to the following password." +
                    " For security reasons, please login and use the 'My Account' page to reset your password.");
                message.WriteLine();
                message.WriteLine("Password: "******"Your request has been submitted. A new password will be created and emailed to you at the email address specified.");
                    lblResponse.Visible = true;
                }
                catch (Exception ex)
                {
                    // trouble sending request for password
                    // Report detailed SMTP Errors
                    string smtpErrorMsg;
                    smtpErrorMsg = "Exception: " + ex.Message;
                    //check the InnerException
                    if (ex.InnerException != null)
                        smtpErrorMsg += "<br>Inner Exceptions:";
                    while (ex.InnerException != null)
                    {
                        smtpErrorMsg += "<br>" + ex.InnerException.Message;
                        ex = ex.InnerException;
                    }

                    lblResponse.Text = Utilities.FormatErrorMessage("Trouble sending email. Your request could not be submitted - please inform an administrator.<br>" + smtpErrorMsg);
                    lblResponse.Visible = true;
                }
            }
        }
Пример #2
0
    public static bool checkUser(string username)
    {
        AuthorizationWrapperClass wrapper = new AuthorizationWrapperClass();
            int userID = -1;
            try
            {
                userID = wrapper.GetUserIDWrapper(username);
                if (userID > 0)
                    return true;
                else
                    return false;

            }
            catch
            {
                return false;
            }
    }
Пример #3
0
        protected void btnSubmit_Click(object sender, System.EventArgs e)
        {
            AuthorizationWrapperClass wrapper = new AuthorizationWrapperClass();
            if(txtUsername.Text == "")
            {
                lblResponse.Text = Utilities.FormatErrorMessage("Missing user ID field.");
                lblResponse.Visible = true;
                return;
            }
            else
            {
                string userName = txtUsername.Text;
                int userID = wrapper.GetUserIDWrapper(userName) ;
                if (txtEmail.Text == "")
                {
                    lblResponse.Text = Utilities.FormatErrorMessage("Missing email field.");
                    lblResponse.Visible = true;
                    return;
                }
                else
                {
                    string email = txtEmail.Text ;
                    User[] lostPassUsers = wrapper.GetUsersWrapper (new int[]{userID});

                    if (lostPassUsers[0].userID == 0)
                    {
                        // userID does not exist in the database
                        lblResponse.Text = Utilities.FormatErrorMessage("This user does not exist.");
                        lblResponse.Visible = true;

                    }
                    else if( email.ToLower () != wrapper.GetUsersWrapper (new int[] {userID})[0].email.ToLower ())
                    {
                        // email does not match email record in our database
                        lblResponse.Text = Utilities.FormatErrorMessage("Please use the user ID AND email you were registered with.");
                        lblResponse.Visible = true;
                    }
                    else // send password to requestor's email address
                    {
                        MailMessage mail = new MailMessage();
                        mail.From = registrationMailAddress;
                        mail.To = email;
                        mail.Subject = "[iLabs] Service Broker Password Reminder" ;
                        mail.Body = "Username: "******"\n\r";
                        mail.Body += "Email:  " + email + "\n\r\n\r";
                        mail.Body +="Your old password has been reset to the following password. For security reasons, please login and use the 'My Account' page to reset your password.\n\r\n\r";
                        mail.Body += "Password: "******"127.0.0.1";
                        try
                        {
                            SmtpMail.Send(mail);

                            // email sent message
                            lblResponse.Text = Utilities.FormatConfirmationMessage("Your request has been submitted. A new password will be created and emailed to the email address you entered below.");
                            lblResponse.Visible = true;
                        }
                        catch (Exception ex)
                        {
                            // trouble sending request for password
                            // Report detailed SMTP Errors
                            string smtpErrorMsg;
                            smtpErrorMsg = "Exception: " + ex.Message;
                            //check the InnerException
                            if (ex.InnerException != null)
                                smtpErrorMsg += "<br>Inner Exceptions:";
                            while( ex.InnerException != null )
                            {
                                smtpErrorMsg += "<br>" +  ex.InnerException.Message;
                                ex = ex.InnerException;
                            }

                            lblResponse.Text = Utilities.FormatErrorMessage("Trouble sending email. Your request could not be submitted - please inform an administrator.<br>" + smtpErrorMsg);
                            lblResponse.Visible = true;
                        }
                    }
                }
            }
        }