本文整理汇总了PHP中Zend_Auth类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Auth类的具体用法?PHP Zend_Auth怎么用?PHP Zend_Auth使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Auth类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: isLoggedIn
/**
* Check, if user is logged in
*
* @param no parameters
* @return bool logged in status
*/
public function isLoggedIn()
{
if ($this->_zendAuth === null) {
$this->_zendAuth = Zend_Auth::getInstance();
}
return $this->_zendAuth->hasIdentity();
}
开发者ID:Ewaldaz,项目名称:Be-your-light,代码行数:13,代码来源:Authentication.php
示例2: preDispatch
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
if ($request->getParam('sid') !== null && $request->getParam('PHPSESSID') === null) {
$request->setParam('PHPSESSID', $request->getParam('sid'));
}
if ($request->getParam('PHPSESSID') === null) {
$module = strtolower($request->getModuleName());
$controller = strtolower($request->getControllerName());
$action = strtolower($request->getActionName());
$route = $module . '/' . $controller . '/' . $action;
if (!in_array($route, $this->_whitelist)) {
if (is_null($this->_auth)) {
$auth = Zend_Auth::getInstance();
$auth->setStorage(new Zend_Auth_Storage_Session($this->getStorage()));
$this->_auth = $auth;
}
if (!$this->_auth->hasIdentity()) {
$errorHandler = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
$errorHandler->type = 'EXCEPTION_NOT_ALLOWED';
$errorHandler->exception = new Zend_Controller_Action_Exception('No credentials available');
$errorHandler->request = clone $request;
$request->setParam('error_handler', $errorHandler)->setModuleName($this->getErrorHandlerModule())->setControllerName($this->getErrorHandlerController())->setActionName($this->getErrorHandlerAction());
} else {
$this->_auth->getIdentity()->connect();
$this->_auth->getIdentity()->refresh();
}
}
}
}
开发者ID:hausdesign,项目名称:zf-library,代码行数:29,代码来源:Auth.php
示例3: testSuccess
public function testSuccess()
{
$this->adapter->setIdentity('test')->setCredential('test');
$result = $this->auth->authenticate($this->adapter);
$this->assertTrue($result->isValid());
$this->assertEquals(Zend_Auth_Result::SUCCESS, $result->getCode());
$this->assertTrue(is_object($this->adapter->getResultUserData()));
}
开发者ID:utachkin,项目名称:Rediska,代码行数:8,代码来源:Auth.php
示例4: testFailure
/**
* Ensure expected behavior upon authentication failure
*
* @return void
*/
public function testFailure()
{
$auth = new Zend_Auth(new Zend_AuthTest_Failure_Adapter(), false);
$options = array();
$token = $auth->authenticate($options);
$this->assertFalse($token->isValid());
$this->assertTrue('someIdentity' === $token->getIdentity());
$this->assertTrue('Failure Message' === $token->getMessage());
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:14,代码来源:AuthTest.php
示例5: preDispatch
/**
* Check permissions before dispatch process
*
* @throws Zend_Auth_Adapter_Exception if answering the authentication query is impossible
* @param Zend_Controller_Request_Abstract $request
* @return void
*/
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$resource = $request->getControllerName();
$action = $request->getActionName();
if ($this->_auth->hasIdentity()) {
$identity = $this->_auth->getStorage()->read();
$role = $identity->role;
} else {
$role = $this->_defaultRole;
}
if ($this->_acl->has($resource) && !$this->_acl->isAllowed($role, $resource, $action)) {
$request->setControllerName('error')->setActionName('deny');
}
}
开发者ID:nuxwin,项目名称:i-PMS,代码行数:21,代码来源:PermissionsCheck.php
示例6: preDispatch
/**
* preDispatch
*
* Funcion que se ejecuta antes de que lo haga el FrontController
*
* @param Zend_Controller_Request_Abstract $request Peticion HTTP realizada
* @return
* @uses Zend_Auth
*
*/
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$controllerName = $request->getControllerName();
// Si el usuario esta autentificado
if ($this->_auth->hasIdentity()) {
} else {
// Si el Usuario no esta identificado y no se dirige a la página de Login
if ($controllerName != 'login') {
// Mostramos al usuario el Formulario de Login
$request->setControllerName("login");
$request->setActionName("index");
}
}
}
开发者ID:JosefinaArayaTapia,项目名称:Capicua-Restobar,代码行数:24,代码来源:CheckAccess.php
示例7: getInstance
/**
* Returns an instance of Zend_Auth
*
* Singleton pattern implementation
*
* @return Zend_Auth Provides a fluent interface
*/
public static function getInstance()
{
if (null === self::$_instance) {
self::$_instance = new self();
}
return self::$_instance;
}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:14,代码来源:Auth.php
示例8: preDispatch
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$auth = Zend_Auth::getInstance();
$isAllowed = false;
$controller = $request->getControllerName();
$action = $request->getActionName();
// Generate the resource name
$resourceName = $controller . '/' . $action;
// Don't block errors
if ($resourceName == 'error/error') {
return;
}
$resources = $this->acl->getResources();
if (!in_array($resourceName, $resources)) {
$request->setControllerName('error')->setActionName('error')->setDispatched(true);
throw new Zend_Controller_Action_Exception('This page does not exist', 404);
return;
}
// Check if user can access this resource or not
$isAllowed = $this->acl->isAllowed(Zend_Registry::get('role'), $resourceName);
// Forward user to access denied or login page if this is guest
if (!$isAllowed) {
if (!Zend_Auth::getInstance()->hasIdentity()) {
$forwardAction = 'login';
} else {
$forwardAction = 'deny';
}
$request->setControllerName('index')->setActionName($forwardAction)->setDispatched(true);
}
}
开发者ID:georgepaul,项目名称:socialstrap,代码行数:30,代码来源:AccessCheck.php
示例9: _initView
protected function _initView()
{
// Start initail view
$this->bootstrap('layout');
$config = $this->getOption('views');
$resources = $this->getOption('resources');
$view = new Zend_View();
if (isset($resources['layout']['layoutPath'])) {
$view->assign('layoutRootPath', $resources['layout']['layoutPath']);
}
$this->bootstrap('db');
Zend_Loader::loadClass('Ht_Utils_SystemSetting');
$sysSetting = Ht_Utils_SystemSetting::getSettings();
$view->assign('sysSetting', $sysSetting);
$view->assign('profile', Zend_Auth::getInstance()->getIdentity());
Zend_Loader::loadClass("Ht_Model_SystemSetting");
$this->setSystemLogConfiguration($sysSetting);
// use the viewrenderer to keep the code DRY
// instantiate and add the helper in one go
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
$viewRenderer->setView($view);
$viewRenderer->setViewSuffix('phtml');
// add it to the action helper broker
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
/**
* Set inflector for Zend_Layout
*/
$inflector = new Zend_Filter_Inflector(':script.:suffix');
$inflector->addRules(array(':script' => array('Word_CamelCaseToDash', 'StringToLower'), 'suffix' => 'phtml'));
// Initialise Zend_Layout's MVC helpers
$this->getResource('layout')->setLayoutPath(realpath($resources['layout']['layoutPath']))->setView($view)->setContentKey('content')->setInflector($inflector);
return $this->getResource('layout')->getView();
}
开发者ID:kangza,项目名称:hagtag,代码行数:33,代码来源:Bootstrap.php
示例10: indexAction
public function indexAction()
{
// display the profile form and populate if profile exists
$request = $this->getRequest();
$form = new Application_Form_Profile();
$auth = Zend_Auth::getInstance();
$identity = $auth->getIdentity();
$profileMapper = new Application_Model_ProfileMapper();
$profile = new Application_Model_Profile();
$exists = $profileMapper->exists($identity->id);
if ($request->isPost()) {
if ($form->isValid($request->getPost())) {
$profile->setOptions($form->getValues());
$profile->setUserId($identity->id);
$profileMapper->save($profile, $exists);
// display success message
$this->view->msg = "<p class='msg'>Profile saved</p>";
}
} else {
$profileMapper->find($identity->id, $profile);
$data = array('first_name' => $profile->getFirstName(), 'last_name' => $profile->getLastName(), 'birthdate' => date_format(new DateTime($profile->getBirthdate()), 'Y-m-d'), 'gender' => $profile->getGender());
$form->populate($data);
}
$this->view->form = $form;
}
开发者ID:jingjangjung,项目名称:WinsAndWants,代码行数:25,代码来源:ProfileController.php
示例11: init
public function init($styles = array())
{
// Init messages
$this->view->message = array();
$this->view->infoMessage = array();
$this->view->errorMessage = array();
$this->messenger = new Zend_Controller_Action_Helper_FlashMessenger();
$this->messenger->setNamespace('messages');
$this->_helper->addHelper($this->messenger);
$this->errorMessenger = new Zend_Controller_Action_Helper_FlashMessenger();
$this->errorMessenger->setNamespace('errorMessages');
$this->_helper->addHelper($this->errorMessenger);
$this->infoMessenger = new Zend_Controller_Action_Helper_FlashMessenger();
$this->infoMessenger->setNamespace('infoMessages');
$this->_helper->addHelper($this->infoMessenger);
// Setup breadcrumbs
$this->view->breadcrumbs = $this->buildBreadcrumbs($this->getRequest()->getRequestUri());
$this->view->user = Zend_Auth::getInstance()->getIdentity();
// Set the menu active element
$uri = $this->getRequest()->getPathInfo();
if (strrpos($uri, '/') === strlen($uri) - 1) {
$uri = substr($uri, 0, -1);
}
if (!is_null($this->view->navigation()->findByUri($uri))) {
$this->view->navigation()->findByUri($uri)->active = true;
}
$this->view->styleSheets = array_merge(array('css/styles.css'), $styles);
$translate = Zend_Registry::get('tr');
$this->view->tr = $translate;
$this->view->setEscape(array('Lupin_Security', 'escape'));
}
开发者ID:crlang44,项目名称:frapi,代码行数:31,代码来源:Base.php
示例12: preRender
public function preRender()
{
if (Zend_Auth::getInstance()->hasIdentity()) {
$controller = sgContext::getInstance()->getController();
if ($controller instanceof FlatCMSPluginController) {
$session = new Zend_Session_Namespace(Zend_Auth::getInstance()->getStorage()->getNamespace());
$session->FlatCMSEditorPluginFileMTime = filemtime(FlatCMSPluginPageModel::getPagePath(sgContext::getInstance()->getCurrentPath()));
//figure out better way to handle this so libraries aren't double loaded
$controller->scripts[] = sgToolkit::url('/js/FlatCMSEditorPlugin/jquery.min.js');
$controller->scripts[] = sgToolkit::url('/js/FlatCMSEditorPlugin/jquery.jeditable.mini.js');
$controller->scripts[] = sgToolkit::url('/js/FlatCMSEditorPlugin/jquery.jeditable.autogrow.js');
$controller->scripts[] = sgToolkit::url('/js/FlatCMSEditorPlugin/tinymce/jscripts/tiny_mce/jquery.tinymce.js');
$controller->scripts[] = sgToolkit::url('/js/FlatCMSEditorPlugin/jquery.jeditable.tinymce.js');
$controller->scripts[] = sgToolkit::url('/js/FlatCMSEditorPlugin/init.js');
$controller->js_settings['FlatCMSEditorPlugin'] = array('saveURL' => sgToolkit::url(sgConfiguration::get('routing.FlatCMSEditorPlugin_save.path')), 'currentPath' => sgContext::getInstance()->getCurrentPath());
if (isset($controller->content) && is_array($controller->content)) {
$textarea_fields = sgConfiguration::get('settings.FlatCMSEditorPlugin.textarea_fields', array());
foreach ($controller->content as $key => &$field) {
if (in_array($key, $textarea_fields)) {
$field = '<div class="editable-area" id="' . $key . '">' . $field . '</div>';
} else {
$field = '<div class="editable" id="' . $key . '">' . $field . '</div>';
}
}
}
}
}
}
开发者ID:superglue,项目名称:FlatCMSEditorPlugin,代码行数:28,代码来源:FlatCMSEditorPluginConfiguration.class.php
示例13: sidebarAction
/**
* Show sidebar
*
* @var int $pcategory Selected category
*
* @throws Exception 404, Category not found
*
*/
public function sidebarAction()
{
$categoriesModel = new Model_DbTable_Categories();
$select = $categoriesModel->select();
$select->order(new Zend_Db_Expr('`order`<=-100'))->order("order");
if (!Zend_Auth::getInstance()->hasIdentity()) {
$select->where("`order` != -100 OR `order` IS NULL");
}
if (NULL != ($category_id = $this->getRequest()->getParam("category"))) {
if (!($category = $categoriesModel->find($category_id)->current())) {
throw new Exception("Category not found", 404);
}
$select->where("parent_id = ?", $category->id);
$categories = $categoriesModel->fetchAll($select);
if (count($categories) == 0) {
$category = $categoriesModel->find($category->parent_id)->current();
$categories = $category->findDependentRowset("Model_DbTable_Categories");
}
} else {
$category = NULL;
$categories = $categoriesModel->fetchAll($select->where("parent_id = ?", 0));
}
$this->view->categories = $categories;
$this->view->category = $category;
$this->view->current = $category_id;
$this->view->catalogs = new Zend_Config_Xml(APPLICATION_PATH . "/config/catalogs.xml");
}
开发者ID:Alpha-Hydro,项目名称:alpha-hydro-antares,代码行数:35,代码来源:SidebarController.php
示例14: preDispatch
function preDispatch()
{
$auth = Zend_Auth::getInstance();
if (!$auth->hasIdentity()) {
$this->_redirect('auth/login');
}
}
开发者ID:kotosha,项目名称:sklepPHP,代码行数:7,代码来源:ZamowieniaController.php
示例15: getSubmissionsForSelect
/**
* Get all accepted submissions belonging to a conference
*
* @param integer $conferenceId conference_id
* @param string $empty String containing the empty value to display
*/
public function getSubmissionsForSelect($conferenceId = null, $empty = null)
{
$return = array();
if ($empty) {
$return[0] = $empty;
}
$identity = Zend_Auth::getInstance()->getIdentity();
$query = 'select st.submission_id, s.title from submission_status st
left join submissions s ON s.submission_id = st.submission_id
where st.status = :status AND s.conference_id = :conference_id';
if (!$identity->isAdmin()) {
// if user is not admin, only show their own submissions
$mySubmissions = implode(",", array_keys($identity->getMySubmissions()));
if (!empty($mySubmissions)) {
$query .= ' and st.submission_id IN (' . $mySubmissions . ')';
} else {
return array();
}
}
$submissions = $this->getAdapter()->query($query, array('status' => $this->_getAcceptedValue(), 'conference_id' => $this->getConferenceId()));
foreach ($submissions as $submission) {
$return[$submission['submission_id']] = $submission['title'];
}
return $return;
}
开发者ID:br00k,项目名称:tnc-web,代码行数:31,代码来源:Submissions.php
示例16: loggedInAs
public function loggedInAs()
{
$Auth = Zend_Auth::getInstance();
$Ret = '';
if ($Auth->hasIdentity()) {
$Username = $Auth->getIdentity()->Nome . ' ' . $Auth->getIdentity()->Cognome;
$Module = Zend_Controller_Front::getInstance()->getRequest()->getModuleName();
$LogoutURL = $this->view->url(array('controller' => 'login', 'action' => 'logout', 'module' => 'default'), 'default', true);
$MessaggiURL = $this->view->url(array('controller' => 'messages', 'action' => 'index', 'module' => 'default'), 'default');
$AdminURL = $this->view->url(array('controller' => 'index', 'action' => 'index', 'module' => $Module == 'admin' ? 'default' : 'admin'), 'default');
#$Ret .= 'Welcome ' . $Username . ' ';
$Ret .= '<a href="' . $MessaggiURL . '">' . $this->view->img('images/icons/mail_24x24.png', array('title' => 'Messages', 'alt' => 'Messages')) . '</a> ';
$Ret .= '<a href="' . $AdminURL . '">' . $this->view->img('images/icons/' . ($Module == 'admin' ? 'magic_wand' : 'wrench') . '_24x24.png', array('title' => $Module == 'admin' ? 'Public' : 'Admin', 'alt' => $Module == 'admin' ? 'Public' : 'Admin')) . '</a> ';
$Ret .= '<a href="' . $LogoutURL . '">' . $this->view->img('images/icons/lock_24x24.png', array('title' => 'Logout', 'alt' => 'Logout')) . '</a>';
return $Ret;
}
$Request = Zend_Controller_Front::getInstance()->getRequest();
$Controller = $Request->getControllerName();
$Action = $Request->getActionName();
if ($Controller == 'login' && $Action == 'index') {
return '';
}
$LoginURL = $this->view->url(array('controller' => 'login', 'action' => 'index'), 'default');
$Ret .= '<a href="' . $LoginURL . '">' . $this->view->img('images/icons/unlock_24x24.png', array('title' => 'Login', 'alt' => 'Login')) . '</a>';
return $Ret;
}
开发者ID:BGCX262,项目名称:zweer-zend-svn-to-git,代码行数:26,代码来源:LoggedInAs.php
示例17: loggedInAs
public function loggedInAs()
{
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()) {
$user = $auth->getIdentity();
if (!isset($user->username)) {
$auth->clearIdentity();
$info = 'logout';
return $info;
}
$logoutUrl = $this->view->url(array('controller' => 'auth', 'action' => 'logout'), null, true);
$url = $this->view->url(array('controller' => 'user', 'action' => 'edit', 'id' => $user->id));
$info = '<div class ="menuButton"><span class="menu">' . $user->username . '</span>';
$info .= '<ul>
<li><a href="' . $url . '">Mon profil</a></li>
<li class="separator"></li>
<li><a href="' . $logoutUrl . '" class="logout">se déconnecter</a></li>
</ul></div>';
return $info;
}
$request = Zend_Controller_Front::getInstance()->getRequest();
$controller = $request->getControllerName();
$action = $request->getActionName();
if ($controller == 'auth' && $action == 'index') {
return '';
}
$form = new Application_Form_Login();
$loginUrl = $this->view->url(array('controller' => 'auth', 'action' => 'index'), null, true);
$info = '<div class ="menuButton"><span class="menu"> Se connecter </span><ul><li class="form">' . $form->setAction($loginUrl) . '</li></ul></div>';
return $info;
//$loginUrl = $this->view->url(array('controller'=>'auth', 'action'=>'index'));
//return '<a href="'.$loginUrl.'">Login</a>';
}
开发者ID:r1zib,项目名称:salesforce,代码行数:33,代码来源:LoggedInAs.php
示例18: preDispatch
/**
* Hook into action controller preDispatch() workflow
*
* @return void
*/
public function preDispatch()
{
$role = Zend_Registry::get('config')->acl->defaultRole;
if ($this->_auth->hasIdentity()) {
$user = $this->_auth->getIdentity();
if (is_object($user) && !empty($user->role)) {
$role = $user->role;
}
}
$request = $this->_action->getRequest();
$controller = $request->getControllerName();
$action = $request->getActionName();
$module = $request->getModuleName();
$this->_controllerName = $controller;
$resource = $controller;
$privilege = $action;
if (!$this->_acl->has($resource)) {
$resource = null;
}
if ($resource == 'error' && $privilege == 'error') {
return;
}
if (!$this->_acl->isAllowed($role, $resource, $privilege)) {
$request->setModuleName('default')->setControllerName('auth')->setActionName('noaccess');
$request->setDispatched(false);
return;
}
}
开发者ID:crlang44,项目名称:frapi,代码行数:33,代码来源:Acl.php
示例19: logoutAction
public function logoutAction()
{
$this->getHelper('contextSwitch')->addActionContext('logout', 'json')->initContext();
if ($this->auth->hasIdentity()) {
$this->auth->clearIdentity();
}
$this->view->response = 'OK';
}
开发者ID:nidzix,项目名称:Newscoop,代码行数:8,代码来源:OmniboxController.php
示例20: getPerson
/** Get the person's identity
* @access public
* @return boolean
*/
public function getPerson()
{
if ($this->_auth->hasIdentity()) {
return $this->_auth->getIdentity();
} else {
return false;
}
}
开发者ID:lesleyauk,项目名称:findsorguk,代码行数:12,代码来源:Identity.php
注:本文中的Zend_Auth类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论