Manager
Authentication manager
class Winter\Storm\Auth\Manager
implements
Illuminate\Contracts\Auth\StatefulGuard
Traits
Trait | Description |
---|---|
Singleton
|
Singleton trait. |
Properties
public
$ipAddress
:
string
= "0.0.0.0"
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
= true
Flag to require users to be activated to login
protected
$sessionKey
:
string
= "winter_auth"
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
= true
Internal flag to toggle using the session for the current authentication request
protected
$useThrottle
:
bool
= true
Flag to enable login throttling
protected $user : Models\User | null
The currently logged in user
protected $userModel : string
User Model Class
protected
$viaRemember
:
bool
= false
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.
Property | Type | Description |
---|---|---|
$credentials | array |
array
The user login details |
$remember | boolean |
boolean
Store a non-expire cookie for the user |
If authentication was successful
public
authenticate (array $credentials, boolean $remember = true
)
Attempts to authenticate the given user according to the passed credentials.
Property | Type | Description |
---|---|---|
$credentials | array |
array
The user login details |
$remember | boolean |
boolean
Store a non-expire cookie for the user |
public check () : bool
Check to see if the user is logged in and activated, and hasn't been banned or suspended.
public createThrottleModel () : Models\Throttle
Creates an instance of the throttle model
public createUserModel () : Models\User
Creates a new instance of the user model
public extendUserQuery (Winter\Storm\Database\Builder $query) : void
Extend the query used for finding the user.
Property | Type | Description |
---|---|---|
$query | Winter\Storm\Database\Builder |
public findThrottleByLogin (string $loginName, string $ipAddress) : Models\Throttle
Find a throttle record by login and ip address
Property | Type | Description |
---|---|---|
$loginName | string |
string
|
$ipAddress | string |
string
|
public
findThrottleByUserId (int $userId, string $ipAddress = null
)
: Models\Throttle
Find a throttle record by user id and ip address
Property | Type | Description |
---|---|---|
$userId | int |
int
|
$ipAddress | string |
string
|
public findUserByCredentials (array $credentials) : Models\User
Finds a user by the given credentials.
Property | Type | Description |
---|---|---|
$credentials | array |
array
The credentials to find a user by |
The requested user
public findUserById (string $id) : mixed
Finds a user by the login value.
Property | Type | Description |
---|---|---|
$id | string |
string
|
(Models\User || null)
public findUserByLogin (string $login) : mixed
Finds a user by the login value.
Property | Type | Description |
---|---|---|
$login | string |
string
|
(Models\User || null)
public getImpersonator () : Models\User | false
Get the original user doing the impersonation
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
(Models\User || null)
public getUser () : mixed
Returns the current user, if any.
(Models\User || null)
public guest () : bool
Determine if the current user is a guest.
public hasUser () : bool
Determine if the guard has a user instance.
public id () : int | null
Get the ID for the currently authenticated user.
public impersonate (Models\User $impersonatee) : void
Impersonates the given user and sets properties in the session but not the cookie.
Property | Type | Description |
---|---|---|
$impersonatee | Models\User |
Models\User
|
public isImpersonator () : bool
Check to see if the current session is being impersonated
public
login (Illuminate\Contracts\Auth\Authenticatable $user, boolean $remember = true
)
Logs in the given user and sets properties in the session.
Property | Type | Description |
---|---|---|
$user | Illuminate\Contracts\Auth\Authenticatable |
Illuminate\Contracts\Auth\Authenticatable
|
$remember | boolean |
boolean
|
public
loginUsingId (mixed $id, boolean $remember = false
)
: Illuminate\Contracts\Auth\Authenticatable | false
Log the given user ID into the application.
Property | Type | Description |
---|---|---|
$id | mixed |
mixed
|
$remember | boolean |
boolean
|
public logout ()
Logs the current user out.
public
once (array $credentials = []
)
: bool
Log a user into the application without sessions or cookies.
Property | Type | Description |
---|---|---|
$credentials | array |
array
|
public onceUsingId (mixed $id) : Illuminate\Contracts\Auth\Authenticatable | false
Log the given user ID into the application without sessions or cookies.
Property | Type | Description |
---|---|---|
$id | mixed |
mixed
|
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
Property | Type | Description |
---|---|---|
$credentials | array |
array
|
$activate | boolean |
boolean
|
$autoLogin | boolean |
boolean
|
public setUser (Illuminate\Contracts\Auth\Authenticatable $user)
Sets the user
Property | Type | Description |
---|---|---|
$user | Illuminate\Contracts\Auth\Authenticatable |
Illuminate\Contracts\Auth\Authenticatable
|
public stopImpersonate ()
Stop the current session being impersonated and authenticate as the impersonator again
public user () : Illuminate\Contracts\Auth\Authenticatable | null
Get the currently authenticated user.
public
validate (array $credentials = []
)
: bool
Validate a user's credentials.
Property | Type | Description |
---|---|---|
$credentials | array |
array
|
public viaRemember () : bool
Determine if the user was authenticated via "remember me" cookie.
protected createUserModelQuery () : Winter\Storm\Database\Builder
protected
getPersistCodeFromSession (boolean $logRemember = false
)
: array | null
Returns the user ID and peristence code from the session or remember cookie
Property | Type | Description |
---|---|---|
$logRemember | boolean |
boolean
Flag to set $this->viaRemember if the persist code was pulled from the cookie |
[user_id, persist_code]
protected init ()
Initializes the singleton
protected
setPersistCodeInSession (Models\User $user, boolean $remember = true
)
: void
Stores the user persistence information in the session (and cookie when $remember = true)
Property | Type | Description |
---|---|---|
$user | Models\User |
Models\User
|
$remember | boolean |
boolean
|
protected
validateInternal (array $credentials = []
)
: Models\User | null
Validate a user's credentials, method used internally.
Property | Type | Description |
---|---|---|
$credentials | array |
array
|
protected validateUserModel (mixed $user) : bool
Perform additional checks on the user model.
Property | Type | Description |
---|---|---|
$user | mixed |
mixed
|
inherited public __clone ()
inherited public __wakeup ()
inherited
public
static
final
forgetInstance ($container = null
)
: void
Forget this singleton's instance if it exists
Property | Type | Description |
---|---|---|
$container | mixed |
mixed
|
inherited
public
static
final
instance ($container = null
)
: static
Create a new instance of this singleton.
Property | Type | Description |
---|---|---|
$container | mixed |
mixed
|
inherited protected final __construct ()
Constructor.
Extended by
Class | Description |
---|---|
AuthManager
|
Back-end authentication manager. |