Вход Регистрация
Файл: gapps/vendor/cartalyst/sentinel/src/Checkpoints/ActivationCheckpoint.php
Строк: 95
<?php

/**
 * Part of the Sentinel package.
 *
 * NOTICE OF LICENSE
 *
 * Licensed under the 3-clause BSD License.
 *
 * This source file is subject to the 3-clause BSD License that is
 * bundled with this package in the LICENSE file.
 *
 * @package    Sentinel
 * @version    2.0.15
 * @author     Cartalyst LLC
 * @license    BSD License (3-clause)
 * @copyright  (c) 2011-2017, Cartalyst LLC
 * @link       http://cartalyst.com
 */

namespace CartalystSentinelCheckpoints;

use 
CartalystSentinelActivationsActivationRepositoryInterface;
use 
CartalystSentinelUsersUserInterface;

class 
ActivationCheckpoint implements CheckpointInterface
{
    use 
AuthenticatedCheckpoint;

    
/**
     * The activation repository.
     *
     * @var CartalystSentinelActivationsActivationRepositoryInterface
     */
    
protected $activations;

    
/**
     * Create a new activation checkpoint.
     *
     * @param  CartalystSentinelActivationsActivationRepositoryInterface  $activations
     * @return void
     */
    
public function __construct(ActivationRepositoryInterface $activations)
    {
        
$this->activations $activations;
    }

    
/**
     * {@inheritDoc}
     */
    
public function login(UserInterface $user)
    {
        return 
$this->checkActivation($user);
    }

    
/**
     * {@inheritDoc}
     */
    
public function check(UserInterface $user)
    {
        return 
$this->checkActivation($user);
    }

    
/**
     * Checks the activation status of the given user.
     *
     * @param  CartalystSentinelUsersUserInterface  $user
     * @return bool
     * @throws CartalystSentinelCheckpointsNotActivatedException
     */
    
protected function checkActivation(UserInterface $user)
    {
        
$completed $this->activations->completed($user);

        if (! 
$completed) {
            
$exception = new NotActivatedException('Your account has not been activated yet.');

            
$exception->setUser($user);

            throw 
$exception;
        }
    }
}
Онлайн: 0
Реклама