Gollem_Auth::canAutoLogin PHP Method

canAutoLogin() public static method

Can we log in without a login screen for the requested backend key?
public static canAutoLogin ( string $key = null ) : array
$key string The backend to login to.
return array The credentials needed to login ('userId', 'password', 'backend') or false if autologin not available.
    public static function canAutoLogin($key = null)
    {
        if (is_null($key)) {
            $key = self::getPreferredBackend();
        }
        if ($key && $GLOBALS['registry']->getAuth() && ($config = self::getBackend($key)) && empty($config['loginparams']) && !empty($config['hordeauth'])) {
            return array('userId' => self::getAutologinID($key), 'password' => $GLOBALS['registry']->getAuthCredential('password'), 'backend_key' => $key);
        }
        return false;
    }

Usage Example

Beispiel #1
0
 /**
  * Return login parameters used on the login page.
  *
  * @return array  See Horde_Core_Auth_Application#authLoginParams().
  */
 public function authLoginParams()
 {
     $params = array();
     if ($GLOBALS['conf']['backend']['backend_list'] == 'shown') {
         $backend_list = array();
         $selected = is_null($this->_oldbackend) ? Horde_Util::getFormData('backend_key', Gollem_Auth::getPreferredBackend()) : $this->_oldbackend;
         foreach (Gollem_Auth::getBackend() as $key => $val) {
             $backend_list[$key] = array('name' => $val['name'], 'selected' => $selected == $key);
             if ($selected == $key) {
                 if (!empty($val['loginparams'])) {
                     foreach ($val['loginparams'] as $param => $label) {
                         $params[$param] = array('label' => $label, 'type' => 'text', 'value' => isset($val['params'][$param]) ? $val['params'][$param] : '');
                     }
                 }
                 if (Gollem_Auth::canAutoLogin($key)) {
                     $params['horde_user'] = null;
                     $params['horde_pass'] = null;
                 }
             }
         }
         $params['backend_key'] = array('label' => _("Backend"), 'type' => 'select', 'value' => $backend_list);
     }
     return array('js_code' => array(), 'js_files' => array(array('login.js', 'gollem'), array('scriptaculous/effects.js', 'horde'), array('redbox.js', 'horde')), 'params' => $params);
 }