SimpleSAML_Auth_Simple::getAttributes PHP Method

getAttributes() public method

This function will retrieve the attributes of the current user if the user is authenticated. If the user isn't authenticated, it will return an empty array.
public getAttributes ( ) : array
return array The users attributes.
    public function getAttributes()
    {
        if (!$this->isAuthenticated()) {
            // Not authenticated
            return array();
        }
        // Authenticated
        $session = SimpleSAML_Session::getSessionFromRequest();
        return $session->getAuthData($this->authSource, 'Attributes');
    }

Usage Example

Beispiel #1
1
 public function __construct()
 {
     //	Obligatoire
     parent::__construct();
     $this->data = array();
     // System FED Oxylane
     if (FEDACTIVE) {
         require __DIR__ . '/../simplesaml/lib/_autoload.php';
         $as = new SimpleSAML_Auth_Simple('Oxylane-sp');
         $isAuth = $as->isAuthenticated();
         if (!$isAuth) {
             $as->requireAuth();
         } else {
             $attributes = $as->getAttributes();
             $this->data['fed']['0'] = $attributes['uid'][0];
             //identifiant
             $this->data['fed']['1'] = $attributes['cn'][0];
             //nom de la personne
             $this->data['fed']['2'] = $attributes['mail'][0];
             //mail de la personne
         }
     } else {
         $this->data['fed']['0'] = "ID";
         $this->data['fed']['1'] = "NOM";
         $this->data['fed']['2'] = "MAIL";
     }
     // END FED
     //	Chargement des ressources pour tout le contrôleur
     $this->load->database();
     $this->load->helper('form');
     $this->load->helper('titreUrl');
     $this->load->helper('convertlien');
     $this->load->library('form_validation');
     $this->load->model('pages_model', 'pm');
     $this->load->model('plannings_model', 'plm');
     $this->load->model('types_model', 'tm');
     $this->load->model('chaines_model', 'cm');
     $this->load->model('groupes_model', 'gm');
     $this->load->model('bandeau_model', 'bm');
     if (FEDLOG) {
         $this->load->model('logs_model', 'lm');
     }
     // Récupération de toute les chaines
     $this->data['chaines'] = $this->cm->getAll();
     $this->data['superadmin'] = true;
     //	Cette méthode permet de changer les délimiteurs par défaut des messages d'erreur (<p></p>).
     $this->form_validation->set_error_delimiters('<p class="alert alert-error fade in"><a class="close" data-dismiss="alert" href="#">&times;</a>', '</p>');
 }
All Usage Examples Of SimpleSAML_Auth_Simple::getAttributes