コード例 #1
0
 /**
  * 函数名称:checkAuth
  * 功能描述:
  * @param $name
  * @param $userid
  * @return bool
  */
 public function checkAuth($name, $userid)
 {
     $auth = new Core_Auth();
     $checkResult = $auth->check($name, $userid);
     if (!$checkResult) {
         $this->redirect($this->adminUrl);
     }
 }
コード例 #2
0
ファイル: Access.php プロジェクト: ptarcher/exercise_mvc
 /**
  * Loads the access levels for the current user.
  *
  * Calls the authentication method to try to log the user in the system.
  * If the user credentials are not correct we don't load anything.
  * If the login/password is correct the user is either the SuperUser or a normal user.
  * We load the access levels for this user for all the websites.
  * 
  * @return true on success, false if reloading access failed (when auth object wasn't specified and user is not enforced to be Super User)
  */
 public function reloadAccess(Core_Auth $auth = null)
 {
     if (!is_null($auth)) {
         $this->auth = $auth;
     }
     // if the Core_Auth wasn't set, we may be in the special case of setSuperUser(), otherwise we fail
     if (is_null($this->auth)) {
         if ($this->isSuperUser()) {
             return $this->reloadAccessSuperUser();
         }
         return false;
     }
     // access = array ( idsite => accessIdSite, idsite2 => accessIdSite2)
     $result = $this->auth->authenticate();
     if (!$result->isValid()) {
         return false;
     }
     $this->login = $result->getIdentity();
     $this->token_auth = $result->getTokenAuth();
     // case the superUser is logged in
     if ($result->getCode() == Core_Auth_Result::SUCCESS_SUPERUSER_AUTH_CODE) {
         return $this->reloadAccessSuperUser();
     }
     // case valid authentification (normal user logged in)
     return true;
 }
コード例 #3
0
<?php

require_once '../../bootstrap.php';
Core_Auth::authorization('repairmanjacktwitterexport');
$oUser = Core_Entity::factory('User')->getCurrent();
$export = new repairmanjacktwitterexport_notifier($oUser->login);
ob_start();
////////////
$oAdmin_Form_Controller = new Admin_Form_Controller();
$oAdmin_Form_Controller->setUp();
$oAdmin_Form_Controller->path('/admin/repairmanjacktwitterexport/index.php');
$oAdmin_Form_Controller->title('Экспорт в Twitter');
$oAdmin_Form_Entity_Form = new Admin_Form_Entity_Form($oAdmin_Form_Controller);
$oAdmin_Form_Entity_Form->action($oAdmin_Form_Controller->getPath());
if ($oAdmin_Form_Controller->getAction() == 'accept') {
    try {
        $export->doAccessToken(Core_Array::getPost('pin', ''));
    } catch (Exception $e) {
        $oAdmin_Form_Entity_Form->add(Core::factory('Admin_Form_Entity_Code')->html('<div id="error">Ошибка ' . $e->getCode() . ': ' . $e->getMessage() . '</div>'));
    }
} elseif ($oAdmin_Form_Controller->getAction() == 'revoke') {
    $export->revokeAuthorization();
}
if (!$export->isAuthorized()) {
    try {
        $export->doRequestToken();
        $aData = $export->getData();
        $oAdmin_Form_Entity_Form->add(Core::factory('Admin_Form_Entity_Code')->html('<div id="message">Первый шаг - авторизация приложения в Twitter! Перейдите по кнопке ниже на страничку Twitter (откроется в новой вкладке/окне) и разрешите приложению доступ к Вашем аккаунту. Скопируйте выданный Twitter код доступа.</div>'))->add(new Admin_Form_Entity_Separator())->add(Core::factory('Admin_Form_Entity_Button')->name('button')->onclick("window.open('http://api.twitter.com/oauth/authorize?oauth_token=" . $aData['oauth_token'] . "')")->value('Авторизация')->class('applyButton'))->add(Core::factory('Admin_Form_Entity_Code')->html('<div id="message">Второй шаг - введите в текстовое поле полученный от Twitter код доступа и нажмите кнопку "Применить".</div>'))->add(new Admin_Form_Entity_Separator())->add(Core::factory('Admin_Form_Entity_Input')->name("pin")->style("width: 100px"))->add(new Admin_Form_Entity_Separator())->add(Core::factory('Admin_Form_Entity_Button')->name('accept')->value('Применить')->class('applyButton')->type('submit')->onclick($oAdmin_Form_Controller->getAdminSendForm('accept')));
    } catch (Exception $e) {
        $oAdmin_Form_Entity_Form->add(Core::factory('Admin_Form_Entity_Code')->html('<div id="error">Ошибка ' . $e->getCode() . ': ' . $e->getMessage() . '</div>'));
    }