addCheckpoint() public méthode

Add a new checkpoint to Sentinel.
public addCheckpoint ( string $key, Cartalyst\Sentinel\Checkpoints\CheckpointInterface $checkpoint ) : void
$key string
$checkpoint Cartalyst\Sentinel\Checkpoints\CheckpointInterface
Résultat void
Exemple #1
0
 /**
  * @param string $context
  * @param SecurityContextConfiguration $configuration
  * @return Security
  */
 public function create($context, SecurityContextConfiguration $configuration)
 {
     $persistences = $this->repositories->createPersistenceRepository($context);
     $roles = $this->repositories->createRoleRepository($context);
     $users = $this->repositories->createUserRepository($context, $persistences, $roles);
     $sentinel = new Sentinel($persistences, $users, $roles, $this->repositories->createActivationRepository($context), $this->container->make(Dispatcher::class));
     foreach ($configuration->listCheckpoints() as $key => $checkpoint) {
         $sentinel->addCheckpoint($key, $this->makeCheckpoint($checkpoint, $configuration));
     }
     $sentinel->setReminderRepository($this->repositories->createReminderRepository($context, $users));
     $sentinel->setRequestCredentials(function () {
         $request = $this->container->make('request');
         $login = $request->getUser();
         $password = $request->getPassword();
         if ($login === null && $password === null) {
             return;
         }
         return compact('login', 'password');
     });
     $sentinel->creatingBasicResponse(function () {
         $headers = ['WWW-Authenticate' => 'Basic'];
         return new Response('Invalid credentials.', 401, $headers);
     });
     $security = new Security($sentinel, $this->repositories->createPermissionRepository($context));
     $this->bindUrlGenerator($security);
     $security->setLoginRoute($configuration->getLoginRoute());
     return $security;
 }
 /**
  * Creates a sentinel instance.
  *
  * @return \Cartalyst\Sentinel\Sentinel
  */
 public function createSentinel()
 {
     $persistence = $this->createPersistence();
     $users = $this->createUsers();
     $roles = $this->createRoles();
     $activations = $this->createActivations();
     $dispatcher = $this->getEventDispatcher();
     $sentinel = new Sentinel($persistence, $users, $roles, $activations, $dispatcher);
     $ipAddress = $this->getIpAddress();
     $checkpoints = $this->createCheckpoints($activations, $ipAddress);
     foreach ($checkpoints as $key => $checkpoint) {
         $sentinel->addCheckpoint($key, $checkpoint);
     }
     $reminders = $this->createReminders($users);
     $sentinel->setActivationRepository($activations);
     $sentinel->setReminderRepository($reminders);
     return $sentinel;
 }
Exemple #3
0
 /**
  * Add a new checkpoint to Sentinel.
  *
  * @param  string              $key
  * @param  CheckpointInterface $checkpoint
  *
  * @return void
  */
 public function addCheckpoint($key, CheckpointInterface $checkpoint)
 {
     $this->sentinel->addCheckpoint($key, $checkpoint);
 }
 /**
  * Add a new checkpoint to Sentinel.
  *
  * @param string $key
  * @param \Cartalyst\Sentinel\Checkpoints\CheckpointInterface $checkpoint
  * @return void 
  * @static 
  */
 public static function addCheckpoint($key, $checkpoint)
 {
     \Cartalyst\Sentinel\Sentinel::addCheckpoint($key, $checkpoint);
 }
 /**
  * Registers sentinel.
  *
  * @return void
  */
 protected function registerSentinel()
 {
     $this->app->singleton('sentinel', function ($app) {
         $sentinel = new Sentinel($app['sentinel.persistence'], $app['sentinel.users'], $app['sentinel.roles'], $app['sentinel.activations'], $app['events']);
         if (isset($app['sentinel.checkpoints'])) {
             foreach ($app['sentinel.checkpoints'] as $key => $checkpoint) {
                 $sentinel->addCheckpoint($key, $checkpoint);
             }
         }
         $sentinel->setActivationRepository($app['sentinel.activations']);
         $sentinel->setReminderRepository($app['sentinel.reminders']);
         $sentinel->setRequestCredentials(function () use($app) {
             $request = $app['request'];
             $login = $request->getUser();
             $password = $request->getPassword();
             if ($login === null && $password === null) {
                 return;
             }
             return compact('login', 'password');
         });
         $sentinel->creatingBasicResponse(function () {
             $headers = ['WWW-Authenticate' => 'Basic'];
             return new Response('Invalid credentials.', 401, $headers);
         });
         return $sentinel;
     });
     $this->app->alias('sentinel', 'Cartalyst\\Sentinel\\Sentinel');
 }