Пример #1
0
function registration_on_confirm(&$api)
{
    $userdb = $api->userdb();
    $user = $userdb->get_user_from_name($_GET['username']);
    assert_user_confirmation_hash_is_valid($user);
    // See if the user still needs to set a password.
    if (!$user->get_password_hash()) {
        $url = new FreechURL(cfg('site_url'));
        $url->set_var('action', 'password_change');
        $url->set_var('username', $user->get_name());
        $url->set_var('hash', $_GET['hash']);
        $api->refer_to($url->get_string());
    }
    // Make the user active.
    $user->set_status(USER_STATUS_ACTIVE);
    $ret = $userdb->save_user($user);
    if ($ret < 0) {
        die('User activation failed');
    }
    // Done.
    include dirname(__FILE__) . '/registration_controller.class.php';
    $registration = new RegistrationController($api);
    $registration->show_done($user);
}