예제 #1
0
/**
 * Declare that content is require user authoriztion and display login form if user isn't logged in
 * @param $bStudio require webmaster authorization
 */
function bx_require_authentication($bStudio = false)
{
    $iRole = BX_DOL_ROLE_MEMBER;
    if ($bStudio) {
        $iRole = BX_DOL_ROLE_ADMIN;
    }
    $sID = isset($_COOKIE['memberID']) ? bx_process_input($_COOKIE['memberID']) : false;
    $sPassword = isset($_COOKIE['memberPassword']) ? bx_process_input($_COOKIE['memberPassword']) : false;
    if (bx_check_login($sID, $sPassword, $iRole)) {
        bx_login_form($bStudio);
    }
    check_logged();
}
예제 #2
0
 function actionAuth()
 {
     $oRequest = OAuth2\Request::createFromGlobals();
     $oResponse = new OAuth2\Response();
     // validate the authorize request
     if (!$this->_oServer->validateAuthorizeRequest($oRequest, $oResponse)) {
         require_once BX_DIRECTORY_PATH_INC . 'design.inc.php';
         $o = json_decode($oResponse->getResponseBody());
         $this->_oTemplate->getPage(false, MsgBox($o->error_description));
     }
     if (!isLogged()) {
         require_once BX_DIRECTORY_PATH_INC . 'design.inc.php';
         $sForceRelocate = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'auth/?client_id=' . bx_get('client_id') . '&response_type=' . bx_get('response_type') . '&state=' . bx_get('state') . '&redirect_uri=' . bx_get('redirect_uri');
         bx_login_form(false, false, $sForceRelocate);
         return;
     }
     $aProfiles = BxDolAccount::getInstance()->getProfiles();
     if (!($iProfileId = $this->_oDb->getSavedProfile($aProfiles)) && empty($_POST)) {
         $oPage = BxDolPage::getObjectInstanceByURI('oauth-authorization');
         $this->_oTemplate->getPage(false, $oPage->getCode());
         return;
     }
     if (!$iProfileId) {
         $iProfileId = bx_get('profile_id');
     }
     $this->_oServer->handleAuthorizeRequest($oRequest, $oResponse, (bool) $iProfileId, $iProfileId);
     $oResponse->send();
 }