예제 #1
0
 protected void GetCurrentVerificationCodeForUser()
 {
     try
     {
         IDBController controller = new SqlController();
         string code = controller.GetCurrentVerificationValueForUser(_currentUser);
         if ("-1".Equals(code))
         {
             GetNumberToSendVerificationTo();
         }
         else
         {
             t2sAccountEmail.Text = controller.GetPairEntryValue("t2sEmailAccount");
             verificationCode.Text = code;
             verificationCodeText.Text = "Register " + code;
         }
     }
     catch (ArgumentNullException)
     {
         // Shouldn't happen
     }
     catch (CouldNotFindException ex)
     {
         Logger.LogMessage("Verification.aspx: " + ex.Message, LoggerLevel.SEVERE);
         errorMessage.Text = "An unknown error occured. Please try again later.3";
         return;
     }
     catch (SqlException ex)
     {
         Logger.LogMessage("Verification.aspx: " + ex.Message, LoggerLevel.SEVERE);
         errorMessage.Text = "An unknown error occured. Please try again later.4";
         return;
     }
 }
예제 #2
0
    /// <summary>
    /// Checks if the given user is verified in the database. If they are not, they are redirected to the
    /// Verification page. Otherwise, they are sent to the Index page. Users are always sent to the
    /// Verification page on first registering with the application.
    /// </summary>
    /// <param name="currentUser">The user to check in the database.</param>
    /// <returns>true if the user is already verified</returns>
    /// <exception cref="SqlException">If there is an issue connecting to the database.</exception>
    public bool isVerified(UserDAO currentUser)
    {
        try
        {
            IDBController controller = new SqlController();
            string val = controller.GetCurrentVerificationValueForUser(currentUser);
            return null == val;
        }
        catch (ArgumentNullException)
        {
            // Shouldn't happen
        }
        catch (CouldNotFindException)
        {
            // User was literally just created, shouldn't be a problem
        }
        // Let the other pages handle SqlExceptions, for displaying to users

        return false;
    }