本文整理汇总了PHP中owa_coreAPI::isCurrentUserAuthenticated方法的典型用法代码示例。如果您正苦于以下问题:PHP owa_coreAPI::isCurrentUserAuthenticated方法的具体用法?PHP owa_coreAPI::isCurrentUserAuthenticated怎么用?PHP owa_coreAPI::isCurrentUserAuthenticated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类owa_coreAPI
的用法示例。
在下文中一共展示了owa_coreAPI::isCurrentUserAuthenticated方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doAction
/**
* Handles request from caller
*
*/
function doAction()
{
owa_coreAPI::debug('Performing Action: ' . get_class($this));
// check if the schema needs to be updated and force the update
// not sure this should go here...
if ($this->is_admin === true) {
// do not intercept if its the updatesApply action or a re-install else updates will never apply
$do = $this->getParam('do');
if ($do != 'base.updatesApply' && !defined('OWA_INSTALLING') && !defined('OWA_UPDATING')) {
if (owa_coreAPI::isUpdateRequired()) {
$this->e->debug('Updates Required. Redirecting action.');
$data = array();
$data['view_method'] = 'redirect';
$data['action'] = 'base.updates';
return $data;
}
}
}
/* Check validity of nonce */
if ($this->is_nonce_required == true) {
$nonce = $this->getParam('nonce');
if ($nonce) {
$is_nonce_valid = $this->verifyNonce($nonce);
}
if (!$nonce || !$is_nonce_valid) {
$this->e->debug('Nonce is not valid.');
$ret = $this->notAuthenticatedAction();
if (!empty($ret)) {
$this->post();
return $ret;
} else {
$this->post();
return $this->data;
}
}
}
/* CHECK USER FOR CAPABILITIES */
if (!owa_coreAPI::isCurrentUserCapable($this->getRequiredCapability())) {
owa_coreAPI::debug('User does not have capability required by this controller.');
// check to see if the user has already been authenticated
if (owa_coreAPI::isCurrentUserAuthenticated()) {
$this->authenticatedButNotCapableAction();
return $this->data;
}
/* PERFORM AUTHENTICATION */
$auth =& owa_auth::get_instance();
$status = $auth->authenticateUser();
// if auth was not successful then return login view.
if ($status['auth_status'] != true) {
$this->notAuthenticatedAction();
return $this->data;
} else {
//check for needed capability again now that they are authenticated
if (!owa_coreAPI::isCurrentUserCapable($this->getRequiredCapability())) {
$this->authenticatedButNotCapableAction();
//needed?
$this->set('go', urlencode(owa_lib::get_current_url()));
// needed? -- set auth status for downstream views
$this->set('auth_status', true);
return $this->data;
}
}
}
// TODO: These sets need to be removed and added to pre(), action() or post() methods
// in various concrete controller classes as they screw up things when
// redirecting from one controller to another.
// set auth status for downstream views
//$this->set('auth_status', true);
//set request params
$this->set('params', $this->params);
// set site_id
$this->set('site_id', $this->get('site_id'));
// set status msg - NEEDED HERE? doesnt owa_ view handle this?
if (array_key_exists('status_code', $this->params)) {
$this->set('status_code', $this->getParam('status_code'));
}
// get error msg from error code passed on the query string from a redirect.
if (array_key_exists('error_code', $this->params)) {
$this->set('error_code', $this->getParam('error_code'));
}
// check to see if the controller has created a validator
if (!empty($this->v)) {
// if so do the validations required
$this->v->doValidations();
//check for errors
if ($this->v->hasErrors === true) {
//print_r($this->v);
// if errors, do the errorAction instead of the normal action
$this->set('validation_errors', $this->getValidationErrorMsgs());
$ret = $this->errorAction();
if (!empty($ret)) {
$this->post();
return $ret;
} else {
$this->post();
return $this->data;
//.........这里部分代码省略.........
示例2: checkCapabilityAndAuthenticateUser
/**
* Checks if the current controller requires privileges and authenticates the user and checks for capabilities
* If the user is not allowed the correct error view is also initialized and the calling method should return
* @uses ->getRequiredCapability and ->getCurrentSiteId
* @param string $capability
* @return boolean
*/
protected function checkCapabilityAndAuthenticateUser($capability)
{
if (!empty($capability) && !owa_coreAPI::isEveryoneCapable($capability)) {
/* PERFORM AUTHENTICATION */
$auth = owa_auth::get_instance();
if (!owa_coreAPI::isCurrentUserAuthenticated()) {
$status = $auth->authenticateUser();
if ($status['auth_status'] != true) {
$this->notAuthenticatedAction();
return false;
}
}
$currentUser = owa_coreAPI::getCurrentUser();
if (!$currentUser->isCapable($this->getRequiredCapability(), $this->getCurrentSiteId())) {
owa_coreAPI::debug('User does not have capability required by this controller.');
$this->authenticatedButNotCapableAction();
//needed?
//$this->set('go', urlencode(owa_lib::get_current_url()));
// needed? -- set auth status for downstream views
//$this->set('auth_status', true);
return false;
}
}
return true;
}