Пример #1
0
 protected void SubmitLogin_OnClick(object sender, EventArgs e)
 {
     try {
         // Disallow empty fields
         if (displayName.Text.Trim().Length == 0 || userName.Text.Trim().Length == 0 || password.Text.Trim().Length == 0)
         {
             throw new ApplicationException("Please provide the required details");
         }
         // Check Username (email)
         var userSearch = SqlHelpers.SelectScalar(SqlStatements.SQL_LOOKUP_USERNAME.FormatWith(userName.Text.Trim().FixSqlString()));
         if (!userSearch.IsNullOrEmpty())
         {
             throw new ApplicationException("Email Address is already in use, please check your entry or use the Forgot Password to reset.");
         }
         // Insert Base Record
         var newRegistration = SqlHelpers.InsertScalar(SqlStatements.SQL_CREATE_USER_REGISTRATION.FormatWith(
                                                           displayName.Text.Trim().FixSqlString(), userName.Text.Trim().FixSqlString(), password.Text.Trim().EncryptString()));
         var usrRec = new SystemUser();
         usrRec.LoadUserDetails(newRegistration);
         SessionInfo.SendRegistrationEmail(usrRec);
         SessionInfo.SendResetEmail(usrRec, password.Text.Trim().EncryptString());
         RegistrationPage.Visible     = false;
         RegistrationThankYou.Visible = true;
     } catch (Exception ex) {
         lErrorMessage.Text = ex.Message;
         SessionInfo.Settings.LogError("Registration Failed", ex);
     }
 }
Пример #2
0
 protected void SubmitLogin_OnClick(object sender, EventArgs e)
 {
     try {
         var s = (new SystemUser()).ValidateUser(userName.Text.Trim());
         if (!s.IsNullOrEmpty())
         {
             var usrRec = new SystemUser();
             usrRec.LoadUserDetails(s);
             var tempPassword = usrRec.ResetUserPassword(s);
             SessionInfo.SendResetEmail(usrRec, tempPassword);
             lErrorMessage.Text  = "A password reset has been emailed";
             SubmitLogin.Visible = false;
             ReturnToLogin.Text  = "Done";
         }
         else
         {
             lErrorMessage.Text = "Email address not found";
         }
     } catch (Exception ex) {
         lErrorMessage.Text = ex.Message;
         SessionInfo.Settings.LogError("User: Forgot Password", ex);
     }
 }