<?php

/**
 * Switches the current session user to the original user
 *
 * @throws QUI\Exception
 */

use QUI\MasterLogin\Manager;
use QUI\MasterLogin\PermissionDeniedException;

QUI::getAjax()->registerFunction(
    'package_quiqqer_masterlogin_ajax_frontend_logBack',
    function () {
        Manager::checkUsePermission();

        try {
            Manager::logBack();
        } catch (PermissionDeniedException $Exception) {
            throw $Exception;
        } catch (Exception $Exception) {
            QUI\System\Log::writeException($Exception);
        }
    },
    [],
    'Permission::checkUser'
);
