Example #1
0
 private function update($name, $description)
 {
     $permission = $this->auth->getPermission($name);
     $permission->description = $description;
     $this->auth->update($name, $permission);
     $this->stdout("Updated: {$name}\n", Console::FG_GREEN);
 }
Example #2
0
 // Add default user group mapping
 echo ' - Fill user group maps table<BR>';
 $groupM = new groupManager();
 $userM = new userManager();
 if ($groupM->getGroupUserMap($groupM->getId('admins'), $userM->getIdByName('admin')) == 0) {
     $groupM->addGroupUserMap($groupM->getId('admins'), $userM->getIdByName('admin'));
 }
 if ($groupM->getGroupUserMap($groupM->getId('admins'), $userM->getIdByName('process')) == 0) {
     $groupM->addGroupUserMap($groupM->getId('admins'), $userM->getIdByName('process'));
 }
 if ($groupM->getGroupUserMap($groupM->getId('guests'), $userM->getIdByName('#core#_#0#')) == 0) {
     $groupM->addGroupUserMap($groupM->getId('guests'), $userM->getIdByName('#core#_#0#'));
 }
 // Add default auth
 echo ' - Fill auths table<BR>';
 $authM = new authManager();
 $authMethodM = new authMethodManager();
 $userM = new userManager();
 if ($authM->getId($userM->getIdByName('admin'), $authMethodM->getId('LOCAL')) == 0) {
     $authM->create($userM->getIdByName('admin'), $authMethodM->getId('LOCAL'), 'admin', 'gob', 'lib/avatars/brain.jpg', '', '', 'admin');
 }
 // Add default access
 echo ' - Fill access table<BR>';
 $accessM = new accessManager();
 $objectM = new objectManager();
 $groupM = new groupManager();
 $pluginM = new pluginManager();
 if ($accessM->getId($objectM->getId(getTableId('core_groups'), $groupM->getId('admins')), $objectM->getId(getTableId('core_plugins'), $pluginM->getId('core'))) == 0) {
     $accessM->create($objectM->getId(getTableId('core_groups'), $groupM->getId('admins')), $objectM->getId(getTableId('core_plugins'), $pluginM->getId('core')), 100);
 }
 if ($accessM->getId($objectM->getId(getTableId('core_groups'), $groupM->getId('members')), $objectM->getId(getTableId('core_plugins'), $pluginM->getId('core'))) == 0) {
 /**
  * Called from indexController();
  */
 public function logOut()
 {
     include_once _AUTH_MANAGER_;
     authManager::logOut($this->view);
 }
Example #4
0
 function register($method, $name, $password, $avatar, $lastName, $firstName, $mail, $isSendMail = 'TRUE')
 {
     $authM = new authManager();
     $authMethodM = new authMethodManager();
     $groupM = new groupManager();
     // Check if the user already exist
     if ($mail != '' && mailCheck($mail) && $this->getId($mail) == 0) {
         // $authM->getId($userId,$methodId) && ($method,$mail,$password) == 0
         // Generate a password
         $generatedPassword = stringGenerate();
         if ($isSendMail == 'TRUE') {
             // On envoie le mail de confirmation avec le mot de passe
             $sujet = 'Création d\'un compte ' . get_ini('APPLICATION_NAME');
             $message = '
         	            Bonjour,<br />
         	            <br />
         	            Voici vos identifiants pour l\'application ' . get_ini('APPLICATION_NAME') . '<br />
         	            Login: <strong>' . $mail . '</strong><br />
         	            Password: <strong>' . $generatedPassword . '</strong><br />
         	            <br />
         	            Merci!<br />
         	            <br />
         	            ' . get_ini('ADMIN_MAIL') . '
         	            ';
             $destinataire = strtolower($mail);
             $headers = "From: " . get_ini('ADMIN_MAIL') . "\n";
             $headers .= "Reply-To: " . get_ini('ADMIN_MAIL') . "\n";
             $headers .= "Content-Type: text/html; charset=\"UTF-8\"";
             if (!mail($destinataire, $sujet, $message, $headers)) {
                 echo "Une erreur c'est produite lors de l'envois de l'email.";
             }
         }
         // On créé l'utilisateur
         $q0_last_insert = $this->create($name, $avatar, $mail);
         // On ajoute la méthode de connexion locale
         $authM->create($q0_last_insert, $authMethodM->getId('LOCAL'), $name, $generatedPassword, $avatar, $lastName, $firstName, $mail);
         // On ajoute le groupe par défaut si il y en a un
         if (get_ini('default_group') != '') {
             $groupM->addGroupUserMap($groupM->getId(get_ini('default_group')), $q0_last_insert);
         }
         // On ajoute d'éventuelle autre méthode d'authentification (Facebook, google, ...)
         switch ($method) {
             case 'LDAP':
                 $authM->create($q0_last_insert, $authMethodM->getId('LDAP'), strtolower($name), '', get_ini('DEFAULT_AVATAR'), '', '', $mail, 'FALSE');
                 break;
             case 'FACEBOOK':
                 $authM->create($q0_last_insert, $authMethodM->getId('FACEBOOK'), $name, $password, $avatar, $lastName, $firstName, $mail);
                 break;
             case 'GOOGLE':
                 $authM->create($q0_last_insert, $authMethodM->getId('GOOGLE'), $name, $password, $avatar, $lastName, $firstName, $mail);
                 break;
         }
     } else {
         // Todo error
     }
 }