public function upgradeTemporaryUser(UserInterface $user, $values = [])
    {
        if (!$user->isTemporary()) {
            throw new AuthException('Cannot upgrade a non-temporary account');
        }

        $values = array_replace($values, [
            'created_at' => Utility::unixToDb(time()),
            'enabled' => true,
        ]);

        $user->grantAllPermissions();

        if (!$user->set($values)) {
            $user->enforcePermissions();

            throw new AuthException('Could not upgrade temporary account: '.implode($user->getErrors()->all()));
        }

        // remove temporary and unverified links
        $app = $user->getApp();
        $app['database']->getDefault()
            ->delete('UserLinks')
            ->where('user_id', $user->id())
            ->where(function ($query) {
                return $query->where('type', UserLink::TEMPORARY)
                    ->orWhere('type', UserLink::VERIFY_EMAIL);
            })
            ->execute();
        $user->clearTemporaryLink();

        // send the user a welcome message
        $user->sendEmail('welcome');

        $user->enforcePermissions();

        return $this;
    }