Skip to content

[TO CLARIFY] Account Re-Verification on Email Change #705

@videsignz

Description

@videsignz

I was thinking...
If we use email verification for an account on creation, why would we not do the same when a user changes their email?

To me this only makes sense. It could go something like this...

  1. User changes email and is logged out
  2. User DB status changes back to inactive
  3. Email resent to verify
  4. Link clicked to reactivate

Obviously there should be some sort of notification shown to the user alerting them that their account will be set back to inactive.

Thoughts?

Here is a quick setup for the function (Not tested)

    public static function saveNewEmailAddress($user_id, $new_user_email)
    {
        $database = DatabaseFactory::getFactory()->getConnection();
        $user_activation_hash = sha1(uniqid(mt_rand(), true));

        $query = $database->prepare("UPDATE users SET user_email = :user_email, user_active = :user_active, user_activation_hash = :user_activation_hash WHERE user_id = :user_id LIMIT 1");
        $query->execute(array(':user_email' => $new_user_email, ':user_active' => 0, ':user_activation_hash' => $user_activation_hash, ':user_id' => $user_id));
        $count =  $query->rowCount();
        if ($count == 1) {
            if(RegistrationModel::sendVerificationEmail($user_id, $new_user_email, $user_activation_hash, true)){
                LoginModel::logout();
                Redirect::home();
            }
        }
        return false;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions