Manager

Authentication manager

 class Winter\Storm\Auth\Manager
implements 
    Illuminate\Contracts\Auth\StatefulGuard

Traits

Trait Description
Singleton

Singleton trait.

Properties

public $ipAddress : string

The IP address of this request

protected $groupModel : string

User Group Model Class

protected $impersonator : Models\User | null

The user that is impersonating the currently logged in user when applicable

protected $requireActivation : bool

Flag to require users to be activated to login

protected $sessionKey : string

Key to store the auth session data in

protected $sessionManager : Illuminate\Session\SessionManager

Session manager instance.

protected $throttle : array

In memory throttle cache [md5($userId.$ipAddress) => $this->throttleModel]

protected $throttleModel : string

Throttle Model Class

protected $useSession : bool

Internal flag to toggle using the session for the current authentication request

protected $useThrottle : bool

Flag to enable login throttling

protected $user : Models\User | null

The currently logged in user

protected $userModel : string

User Model Class

protected $viaRemember : bool

Indicates if the user was authenticated via a recaller cookie.

Methods

public attempt (array $credentials = [], boolean $remember = false) : bool

Attempt to authenticate a user using the given credentials.

Parameters
Property Description
$credentials
array

The user login details

$remember
boolean

Store a non-expire cookie for the user

Returns
bool

If authentication was successful

public authenticate (array $credentials, boolean $remember = true)

Attempts to authenticate the given user according to the passed credentials.

Parameters
Property Description
$credentials
array

The user login details

$remember
boolean

Store a non-expire cookie for the user

Returns
mixed

public check () : bool

Check to see if the user is logged in and activated, and hasn't been banned or suspended.

Returns
bool

public createThrottleModel () : Models\Throttle

Creates an instance of the throttle model

Returns
Models\Throttle

public createUserModel () : Models\User

Creates a new instance of the user model

Returns
Models\User

public extendUserQuery (Winter\Storm\Database\Builder $query) : void

Extend the query used for finding the user.

Parameters
Returns
void

public findThrottleByLogin (string $loginName, string $ipAddress) : Models\Throttle

Find a throttle record by login and ip address

Parameters
Property Description
$loginName
string
$ipAddress
string
Returns
Models\Throttle

public findThrottleByUserId (int $userId, string $ipAddress = null) : Models\Throttle

Find a throttle record by user id and ip address

Parameters
Property Description
$userId
int
$ipAddress
string
Returns
Models\Throttle

public findUserByCredentials (array $credentials) : Models\User

Finds a user by the given credentials.

Parameters
Property Description
$credentials
array

The credentials to find a user by

Returns
Models\User

The requested user

public findUserById (string $id) : mixed

Finds a user by the login value.

Parameters
Property Description
$id
string
Returns
mixed

(Models\User || null)

public findUserByLogin (string $login) : mixed

Finds a user by the login value.

Parameters
Property Description
$login
string
Returns
mixed

(Models\User || null)

public getImpersonator () : Models\User | false

Get the original user doing the impersonation

Returns
Models\User | false

Returns the User model for the impersonator if able, false if not

public getRealUser () : mixed

Gets the user for the request, taking into account impersonation

Returns
mixed

(Models\User || null)

public getUser () : mixed

Returns the current user, if any.

Returns
mixed

(Models\User || null)

public guest () : bool

Determine if the current user is a guest.

Returns
bool

public hasUser () : bool

Determine if the guard has a user instance.

Returns
bool

public id () : int | null

Get the ID for the currently authenticated user.

Returns
int | null

public impersonate (Models\User $impersonatee) : void

Impersonates the given user and sets properties in the session but not the cookie.

Parameters
Property Description
$impersonatee
Models\User
Returns
void

public isImpersonator () : bool

Check to see if the current session is being impersonated

Returns
bool

public login (Illuminate\Contracts\Auth\Authenticatable $user, boolean $remember = true)

Logs in the given user and sets properties in the session.

Parameters
Property Description
$user
Illuminate\Contracts\Auth\Authenticatable
$remember
boolean
Returns
mixed

public loginUsingId (mixed $id, boolean $remember = false) : Illuminate\Contracts\Auth\Authenticatable | false

Log the given user ID into the application.

Parameters
Property Description
$id
mixed
$remember
boolean
Returns
Illuminate\Contracts\Auth\Authenticatable | false

public logout ()

Logs the current user out.

Returns
mixed

public once (array $credentials = []) : bool

Log a user into the application without sessions or cookies.

Parameters
Property Description
$credentials
array
Returns
bool

public onceUsingId (mixed $id) : Illuminate\Contracts\Auth\Authenticatable | false

Log the given user ID into the application without sessions or cookies.

Parameters
Property Description
$id
mixed
Returns
Illuminate\Contracts\Auth\Authenticatable | false

public register (array $credentials, boolean $activate = false, boolean $autoLogin = true) : Models\User

Registers a user with the provided credentials with optional flags for activating the newly created user and automatically logging them in

Parameters
Property Description
$credentials
array
$activate
boolean
$autoLogin
boolean
Returns
Models\User

public setUser (Illuminate\Contracts\Auth\Authenticatable $user)

Sets the user

Parameters
Property Description
$user
Illuminate\Contracts\Auth\Authenticatable
Returns
mixed

public stopImpersonate ()

Stop the current session being impersonated and authenticate as the impersonator again

Returns
mixed

public user () : Illuminate\Contracts\Auth\Authenticatable | null

Get the currently authenticated user.

Returns
Illuminate\Contracts\Auth\Authenticatable | null

public validate (array $credentials = []) : bool

Validate a user's credentials.

Parameters
Property Description
$credentials
array
Returns
bool

public viaRemember () : bool

Determine if the user was authenticated via "remember me" cookie.

Returns
bool

protected createUserModelQuery () : Winter\Storm\Database\Builder

Prepares a query derived from the user model.

Returns

protected getPersistCodeFromSession (boolean $logRemember = false) : array | null

Returns the user ID and peristence code from the session or remember cookie

Parameters
Property Description
$logRemember
boolean

Flag to set $this->viaRemember if the persist code was pulled from the cookie

Returns
array | null

[user_id, persist_code]

protected init ()

Initializes the singleton

Returns
mixed

protected setPersistCodeInSession (Models\User $user, boolean $remember = true) : void

Stores the user persistence information in the session (and cookie when $remember = true)

Parameters
Property Description
$user
Models\User
$remember
boolean
Returns
void

protected validateInternal (array $credentials = []) : Models\User | null

Validate a user's credentials, method used internally.

Parameters
Property Description
$credentials
array
Returns
Models\User | null

protected validateUserModel (mixed $user) : bool

Perform additional checks on the user model.

Parameters
Property Description
$user
mixed
Returns
bool

inherited public __clone ()

Inherited from Singleton
Returns
mixed

inherited public __wakeup ()

Inherited from Singleton
Returns
mixed

inherited public static final forgetInstance ($container = null) : void

Inherited from Singleton

Forget this singleton's instance if it exists

Parameters
Property Description
$container
mixed
Returns
void

inherited public static final instance ($container = null) : static

Inherited from Singleton

Create a new instance of this singleton.

Parameters
Property Description
$container
mixed
Returns
static

inherited protected final __construct ()

Inherited from Singleton

Constructor.

Returns
mixed

Extended by

Class Description
AuthManager

Back-end authentication manager.

Copyright © 2024 Winter CMS