The class supports user authentication, login and logout, persisting the session data and initializing the user object from a database row. It functions as abstract parent class for the "BackendUser" and "FrontendUser" classes of the core. Usage: $user = BackendUser::getInstance(); if ($user->findBy('username', 'leo')) { echo $user->name; }
Inheritance: extends System
コード例 #1
0
ファイル: ContaoToken.php プロジェクト: contao/core-bundle
 /**
  * Constructor.
  *
  * @param User $user
  *
  * @throws UsernameNotFoundException
  */
 public function __construct(User $user)
 {
     if (!$user->authenticate()) {
         throw new UsernameNotFoundException('Invalid Contao user given.');
     }
     $this->setUser($user);
     $this->setAuthenticated(true);
     parent::__construct($this->getRolesFromUser($user));
 }
コード例 #2
0
 /**
  * Check if user authentication succeeds on phpbb site and if so update contao member
  *
  * @param $username
  * @param $password
  * @param User $user
  * @return bool
  */
 public function onCheckCredentials($username, $password, User $user)
 {
     // Only try to login if it's frontend user
     if ($user instanceof FrontendUser) {
         $loginResult = System::getContainer()->get('phpbb_bridge.connector')->validateLogin($username, $password);
         // Login was successful on phpbb side. Maybe user changed his password. So do we for contao then
         if ($loginResult === true) {
             $user->password = Encryption::hash($password);
             $user->save();
             return true;
         }
     }
     return false;
 }
コード例 #3
0
ファイル: BackendUser.php プロジェクト: Mozan/core-bundle
 /**
  * Restore the original numeric file mounts (see #5083)
  */
 public function save()
 {
     $filemounts = $this->filemounts;
     if (!empty($this->arrFilemountIds)) {
         $this->arrData['filemounts'] = $this->arrFilemountIds;
     }
     parent::save();
     $this->filemounts = $filemounts;
 }