PHP Class Cartalyst\Sentinel\Sentinel

Inheritance: use trait Cartalyst\Support\Traits\EventTrait
Datei anzeigen Open project: cartalyst/sentinel Class Usage Examples

Protected Properties

Property Type Description
$activations Cartalyst\Sentinel\Activations\ActivationRepositoryInterface The Activations repository.
$basicResponse Closure The closure used to create a basic response for failed HTTP auth.
$checkpoints array Array that holds all the enabled checkpoints.
$checkpointsStatus boolean Flag for the checkpoint status.
$persistences Cartalyst\Sentinel\Persistences\PersistenceRepositoryInterface The Persistence repository.
$reminders Cartalyst\Sentinel\Reminders\ReminderRepositoryInterface The Reminders repository.
$requestCredentials Closure The closure to retrieve the request credentials.
$roles Cartalyst\Sentinel\Roles\RoleRepositoryInterface The Role repository.
$throttle Cartalyst\Sentinel\Throttling\ThrottleRepositoryInterface The Throttle repository.
$user Cartalyst\Sentinel\Users\UserInterface The current cached, logged in user.
$userMethods array Cached, available methods on the user repository, used for dynamic calls.
$users Cartalyst\Sentinel\Users\UserRepositoryInterface The User repository.

Public Methods

Method Description
__call ( string $method, array $parameters ) : mixed Dynamically pass missing methods to Sentinel.
__construct ( Cartalyst\Sentinel\Persistences\PersistenceRepositoryInterface $persistences, Cartalyst\Sentinel\Users\UserRepositoryInterface $users, Cartalyst\Sentinel\Roles\RoleRepositoryInterface $roles, Cartalyst\Sentinel\Activations\ActivationRepositoryInterface $activations, Illuminate\Events\Dispatcher $dispatcher ) : void Create a new Sentinel instance.
activate ( mixed $user ) : boolean Activates the given user.
addCheckpoint ( string $key, Cartalyst\Sentinel\Checkpoints\CheckpointInterface $checkpoint ) : void Add a new checkpoint to Sentinel.
authenticate ( Cartalyst\Sentinel\Users\UserInterface | array $credentials, boolean $remember = false, boolean $login = true ) : Cartalyst\Sentinel\Users\UserInterface | boolean Authenticates a user, with "remember" flag.
authenticateAndRemember ( Cartalyst\Sentinel\Users\UserInterface | array $credentials ) : Cartalyst\Sentinel\Users\UserInterface | boolean Authenticates a user, with the "remember" flag.
basic ( ) : mixed Attempt to authenticate using HTTP Basic Auth.
bypassCheckpoints ( Closure $callback, array $checkpoints = [] ) : mixed Pass a closure to Sentinel to bypass checkpoints.
check ( ) : Cartalyst\Sentinel\Users\UserInterface | boolean Checks to see if a user is logged in.
checkpointsStatus ( ) : boolean Checks if checkpoints are enabled.
creatingBasicResponse ( Closure $basicResponse ) : void Sets the callback which creates a basic response.
disableCheckpoints ( ) : void Disables checkpoints.
enableCheckpoints ( ) : void Enables checkpoints.
forceAuthenticate ( Cartalyst\Sentinel\Users\UserInterface | array $credentials, boolean $remember = false ) : Cartalyst\Sentinel\Users\UserInterface | boolean Forces an authentication to bypass checkpoints.
forceAuthenticateAndRemember ( Cartalyst\Sentinel\Users\UserInterface | array $credentials ) : Cartalyst\Sentinel\Users\UserInterface | boolean Forces an authentication to bypass checkpoints, with the "remember" flag.
forceCheck ( ) : Cartalyst\Sentinel\Users\UserInterface | boolean Checks to see if a user is logged in, bypassing checkpoints
getActivationRepository ( ) : Cartalyst\Sentinel\Activations\ActivationRepositoryInterface Returns the activations repository.
getBasicResponse ( ) : mixed Sends a response when HTTP basic authentication fails.
getPersistenceRepository ( ) : Cartalyst\Sentinel\Persistences\PersistenceRepositoryInterface Returns the persistences repository.
getReminderRepository ( ) : Cartalyst\Sentinel\Reminders\ReminderRepositoryInterface Returns the reminders repository.
getRequestCredentials ( ) : array Returns the request credentials.
getRoleRepository ( ) : Cartalyst\Sentinel\Roles\RoleRepositoryInterface Returns the role repository.
getThrottleRepository ( ) : Cartalyst\Sentinel\Throttling\ThrottleRepositoryInterface Returns the throttle repository.
getUser ( boolean $check = true ) : Cartalyst\Sentinel\Users\UserInterface Returns the currently logged in user, lazily checking for it.
getUserRepository ( ) : Cartalyst\Sentinel\Users\UserRepositoryInterface Returns the user repository.
guest ( ) : boolean Checks if we are currently a guest.
login ( Cartalyst\Sentinel\Users\UserInterface $user, boolean $remember = false ) : Cartalyst\Sentinel\Users\UserInterface | boolean Persists a login for the given user.
loginAndRemember ( Cartalyst\Sentinel\Users\UserInterface $user ) : Cartalyst\Sentinel\Users\UserInterface | boolean Persists a login for the given user, with the "remember" flag.
logout ( Cartalyst\Sentinel\Users\UserInterface $user = null, boolean $everywhere = false ) : boolean Logs the current user out.
register ( array $credentials, Closure | boolean $callback = null ) : Cartalyst\Sentinel\Users\UserInteface | boolean Registers a user. You may provide a callback to occur before the user is saved, or provide a true boolean as a shortcut to activation.
registerAndActivate ( array $credentials ) : Cartalyst\Sentinel\Users\UserInteface | boolean Registers and activates the user.
removeCheckpoint ( string $key ) : void Removes a checkpoint.
removeCheckpoints ( array $checkpoints = [] ) : void Removes the given checkpoints.
setActivationRepository ( Cartalyst\Sentinel\Activations\ActivationRepositoryInterface $activations ) : void Sets the activations repository.
setPersistenceRepository ( Cartalyst\Sentinel\Persistences\PersistenceRepositoryInterface $persistences ) : void Sets the persistences repository.
setReminderRepository ( Cartalyst\Sentinel\Reminders\ReminderRepositoryInterface $reminders ) : void Sets the reminders repository.
setRequestCredentials ( Closure $requestCredentials ) : void Sets the closure which resolves the request credentials.
setRoleRepository ( Cartalyst\Sentinel\Roles\RoleRepositoryInterface $roles ) : void Sets the role repository.
setThrottleRepository ( Cartalyst\Sentinel\Throttling\ThrottleRepositoryInterface $throttle ) : void Sets the throttle repository.
setUser ( Cartalyst\Sentinel\Users\UserInterface $user ) : void Sets the user associated with Sentinel (does not log in).
setUserRepository ( Cartalyst\Sentinel\Users\UserRepositoryInterface $users ) : void Sets the user repository.
stateless ( Cartalyst\Sentinel\Users\UserInterface | array $credentials ) : Cartalyst\Sentinel\Users\UserInterface | boolean Attempt a stateless authentication.

Protected Methods

Method Description
cycleCheckpoints ( string $method, Cartalyst\Sentinel\Users\UserInterface $user = null, boolean $halt = true ) : boolean Cycles through all the registered checkpoints for a user. Checkpoints may throw their own exceptions, however, if just one returns false, the cycle fails.
getUserMethods ( ) : array Returns all accessible methods on the associated user repository.

Method Details

__call() public method

Dynamically pass missing methods to Sentinel.
public __call ( string $method, array $parameters ) : mixed
$method string
$parameters array
return mixed

__construct() public method

Create a new Sentinel instance.
public __construct ( Cartalyst\Sentinel\Persistences\PersistenceRepositoryInterface $persistences, Cartalyst\Sentinel\Users\UserRepositoryInterface $users, Cartalyst\Sentinel\Roles\RoleRepositoryInterface $roles, Cartalyst\Sentinel\Activations\ActivationRepositoryInterface $activations, Illuminate\Events\Dispatcher $dispatcher ) : void
$persistences Cartalyst\Sentinel\Persistences\PersistenceRepositoryInterface
$users Cartalyst\Sentinel\Users\UserRepositoryInterface
$roles Cartalyst\Sentinel\Roles\RoleRepositoryInterface
$activations Cartalyst\Sentinel\Activations\ActivationRepositoryInterface
$dispatcher Illuminate\Events\Dispatcher
return void

activate() public method

Activates the given user.
public activate ( mixed $user ) : boolean
$user mixed
return boolean

addCheckpoint() public method

Add a new checkpoint to Sentinel.
public addCheckpoint ( string $key, Cartalyst\Sentinel\Checkpoints\CheckpointInterface $checkpoint ) : void
$key string
$checkpoint Cartalyst\Sentinel\Checkpoints\CheckpointInterface
return void

authenticate() public method

Authenticates a user, with "remember" flag.
public authenticate ( Cartalyst\Sentinel\Users\UserInterface | array $credentials, boolean $remember = false, boolean $login = true ) : Cartalyst\Sentinel\Users\UserInterface | boolean
$credentials Cartalyst\Sentinel\Users\UserInterface | array
$remember boolean
$login boolean
return Cartalyst\Sentinel\Users\UserInterface | boolean

authenticateAndRemember() public method

Authenticates a user, with the "remember" flag.
public authenticateAndRemember ( Cartalyst\Sentinel\Users\UserInterface | array $credentials ) : Cartalyst\Sentinel\Users\UserInterface | boolean
$credentials Cartalyst\Sentinel\Users\UserInterface | array
return Cartalyst\Sentinel\Users\UserInterface | boolean

basic() public method

Attempt to authenticate using HTTP Basic Auth.
public basic ( ) : mixed
return mixed

bypassCheckpoints() public method

Pass a closure to Sentinel to bypass checkpoints.
public bypassCheckpoints ( Closure $callback, array $checkpoints = [] ) : mixed
$callback Closure
$checkpoints array
return mixed

check() public method

Checks to see if a user is logged in.
public check ( ) : Cartalyst\Sentinel\Users\UserInterface | boolean
return Cartalyst\Sentinel\Users\UserInterface | boolean

checkpointsStatus() public method

Checks if checkpoints are enabled.
public checkpointsStatus ( ) : boolean
return boolean

creatingBasicResponse() public method

Sets the callback which creates a basic response.
public creatingBasicResponse ( Closure $basicResponse ) : void
$basicResponse Closure
return void

cycleCheckpoints() protected method

Cycles through all the registered checkpoints for a user. Checkpoints may throw their own exceptions, however, if just one returns false, the cycle fails.
protected cycleCheckpoints ( string $method, Cartalyst\Sentinel\Users\UserInterface $user = null, boolean $halt = true ) : boolean
$method string
$user Cartalyst\Sentinel\Users\UserInterface
$halt boolean
return boolean

disableCheckpoints() public method

Disables checkpoints.
public disableCheckpoints ( ) : void
return void

enableCheckpoints() public method

Enables checkpoints.
public enableCheckpoints ( ) : void
return void

forceAuthenticate() public method

Forces an authentication to bypass checkpoints.
public forceAuthenticate ( Cartalyst\Sentinel\Users\UserInterface | array $credentials, boolean $remember = false ) : Cartalyst\Sentinel\Users\UserInterface | boolean
$credentials Cartalyst\Sentinel\Users\UserInterface | array
$remember boolean
return Cartalyst\Sentinel\Users\UserInterface | boolean

forceAuthenticateAndRemember() public method

Forces an authentication to bypass checkpoints, with the "remember" flag.
public forceAuthenticateAndRemember ( Cartalyst\Sentinel\Users\UserInterface | array $credentials ) : Cartalyst\Sentinel\Users\UserInterface | boolean
$credentials Cartalyst\Sentinel\Users\UserInterface | array
return Cartalyst\Sentinel\Users\UserInterface | boolean

forceCheck() public method

Checks to see if a user is logged in, bypassing checkpoints
public forceCheck ( ) : Cartalyst\Sentinel\Users\UserInterface | boolean
return Cartalyst\Sentinel\Users\UserInterface | boolean

getActivationRepository() public method

Returns the activations repository.
public getActivationRepository ( ) : Cartalyst\Sentinel\Activations\ActivationRepositoryInterface
return Cartalyst\Sentinel\Activations\ActivationRepositoryInterface

getBasicResponse() public method

Sends a response when HTTP basic authentication fails.
public getBasicResponse ( ) : mixed
return mixed

getPersistenceRepository() public method

Returns the persistences repository.
public getPersistenceRepository ( ) : Cartalyst\Sentinel\Persistences\PersistenceRepositoryInterface
return Cartalyst\Sentinel\Persistences\PersistenceRepositoryInterface

getReminderRepository() public method

Returns the reminders repository.
public getReminderRepository ( ) : Cartalyst\Sentinel\Reminders\ReminderRepositoryInterface
return Cartalyst\Sentinel\Reminders\ReminderRepositoryInterface

getRequestCredentials() public method

Returns the request credentials.
public getRequestCredentials ( ) : array
return array

getRoleRepository() public method

Returns the role repository.
public getRoleRepository ( ) : Cartalyst\Sentinel\Roles\RoleRepositoryInterface
return Cartalyst\Sentinel\Roles\RoleRepositoryInterface

getThrottleRepository() public method

Returns the throttle repository.
public getThrottleRepository ( ) : Cartalyst\Sentinel\Throttling\ThrottleRepositoryInterface
return Cartalyst\Sentinel\Throttling\ThrottleRepositoryInterface

getUser() public method

Returns the currently logged in user, lazily checking for it.
public getUser ( boolean $check = true ) : Cartalyst\Sentinel\Users\UserInterface
$check boolean
return Cartalyst\Sentinel\Users\UserInterface

getUserMethods() protected method

Returns all accessible methods on the associated user repository.
protected getUserMethods ( ) : array
return array

getUserRepository() public method

Returns the user repository.
public getUserRepository ( ) : Cartalyst\Sentinel\Users\UserRepositoryInterface
return Cartalyst\Sentinel\Users\UserRepositoryInterface

guest() public method

Checks if we are currently a guest.
public guest ( ) : boolean
return boolean

login() public method

Persists a login for the given user.
public login ( Cartalyst\Sentinel\Users\UserInterface $user, boolean $remember = false ) : Cartalyst\Sentinel\Users\UserInterface | boolean
$user Cartalyst\Sentinel\Users\UserInterface
$remember boolean
return Cartalyst\Sentinel\Users\UserInterface | boolean

loginAndRemember() public method

Persists a login for the given user, with the "remember" flag.
public loginAndRemember ( Cartalyst\Sentinel\Users\UserInterface $user ) : Cartalyst\Sentinel\Users\UserInterface | boolean
$user Cartalyst\Sentinel\Users\UserInterface
return Cartalyst\Sentinel\Users\UserInterface | boolean

logout() public method

Logs the current user out.
public logout ( Cartalyst\Sentinel\Users\UserInterface $user = null, boolean $everywhere = false ) : boolean
$user Cartalyst\Sentinel\Users\UserInterface
$everywhere boolean
return boolean

register() public method

Registers a user. You may provide a callback to occur before the user is saved, or provide a true boolean as a shortcut to activation.
public register ( array $credentials, Closure | boolean $callback = null ) : Cartalyst\Sentinel\Users\UserInteface | boolean
$credentials array
$callback Closure | boolean
return Cartalyst\Sentinel\Users\UserInteface | boolean

registerAndActivate() public method

Registers and activates the user.
public registerAndActivate ( array $credentials ) : Cartalyst\Sentinel\Users\UserInteface | boolean
$credentials array
return Cartalyst\Sentinel\Users\UserInteface | boolean

removeCheckpoint() public method

Removes a checkpoint.
public removeCheckpoint ( string $key ) : void
$key string
return void

removeCheckpoints() public method

Removes the given checkpoints.
public removeCheckpoints ( array $checkpoints = [] ) : void
$checkpoints array
return void

setActivationRepository() public method

Sets the activations repository.
public setActivationRepository ( Cartalyst\Sentinel\Activations\ActivationRepositoryInterface $activations ) : void
$activations Cartalyst\Sentinel\Activations\ActivationRepositoryInterface
return void

setPersistenceRepository() public method

Sets the persistences repository.
public setPersistenceRepository ( Cartalyst\Sentinel\Persistences\PersistenceRepositoryInterface $persistences ) : void
$persistences Cartalyst\Sentinel\Persistences\PersistenceRepositoryInterface
return void

setReminderRepository() public method

Sets the reminders repository.
public setReminderRepository ( Cartalyst\Sentinel\Reminders\ReminderRepositoryInterface $reminders ) : void
$reminders Cartalyst\Sentinel\Reminders\ReminderRepositoryInterface
return void

setRequestCredentials() public method

Sets the closure which resolves the request credentials.
public setRequestCredentials ( Closure $requestCredentials ) : void
$requestCredentials Closure
return void

setRoleRepository() public method

Sets the role repository.
public setRoleRepository ( Cartalyst\Sentinel\Roles\RoleRepositoryInterface $roles ) : void
$roles Cartalyst\Sentinel\Roles\RoleRepositoryInterface
return void

setThrottleRepository() public method

Sets the throttle repository.
public setThrottleRepository ( Cartalyst\Sentinel\Throttling\ThrottleRepositoryInterface $throttle ) : void
$throttle Cartalyst\Sentinel\Throttling\ThrottleRepositoryInterface
return void

setUser() public method

Sets the user associated with Sentinel (does not log in).
public setUser ( Cartalyst\Sentinel\Users\UserInterface $user ) : void
$user Cartalyst\Sentinel\Users\UserInterface
return void

setUserRepository() public method

Sets the user repository.
public setUserRepository ( Cartalyst\Sentinel\Users\UserRepositoryInterface $users ) : void
$users Cartalyst\Sentinel\Users\UserRepositoryInterface
return void

stateless() public method

Attempt a stateless authentication.
public stateless ( Cartalyst\Sentinel\Users\UserInterface | array $credentials ) : Cartalyst\Sentinel\Users\UserInterface | boolean
$credentials Cartalyst\Sentinel\Users\UserInterface | array
return Cartalyst\Sentinel\Users\UserInterface | boolean

Property Details

$activations protected_oe property

The Activations repository.
protected ActivationRepositoryInterface,Cartalyst\Sentinel\Activations $activations
return Cartalyst\Sentinel\Activations\ActivationRepositoryInterface

$basicResponse protected_oe property

The closure used to create a basic response for failed HTTP auth.
protected Closure $basicResponse
return Closure

$checkpoints protected_oe property

Array that holds all the enabled checkpoints.
protected array $checkpoints
return array

$checkpointsStatus protected_oe property

Flag for the checkpoint status.
protected bool $checkpointsStatus
return boolean

$persistences protected_oe property

The Persistence repository.
protected PersistenceRepositoryInterface,Cartalyst\Sentinel\Persistences $persistences
return Cartalyst\Sentinel\Persistences\PersistenceRepositoryInterface

$reminders protected_oe property

The Reminders repository.
protected ReminderRepositoryInterface,Cartalyst\Sentinel\Reminders $reminders
return Cartalyst\Sentinel\Reminders\ReminderRepositoryInterface

$requestCredentials protected_oe property

The closure to retrieve the request credentials.
protected Closure $requestCredentials
return Closure

$roles protected_oe property

The Role repository.
protected RoleRepositoryInterface,Cartalyst\Sentinel\Roles $roles
return Cartalyst\Sentinel\Roles\RoleRepositoryInterface

$throttle protected_oe property

The Throttle repository.
protected ThrottleRepositoryInterface,Cartalyst\Sentinel\Throttling $throttle
return Cartalyst\Sentinel\Throttling\ThrottleRepositoryInterface

$user protected_oe property

The current cached, logged in user.
protected UserInterface,Cartalyst\Sentinel\Users $user
return Cartalyst\Sentinel\Users\UserInterface

$userMethods protected_oe property

Cached, available methods on the user repository, used for dynamic calls.
protected array $userMethods
return array

$users protected_oe property

The User repository.
protected UserRepositoryInterface,Cartalyst\Sentinel\Users $users
return Cartalyst\Sentinel\Users\UserRepositoryInterface