Documentation

AuthManager extends Manager
in package

Authentication manager

Table of Contents

$ipAddress  : string
$groupModel  : string
$instance  : mixed
$requireActivation  : bool
$sessionKey  : string
$throttle  : array<string|int, mixed>
$throttleModel  : string
$user  : User
$userModel  : string
$useSession  : bool
$useThrottle  : bool
$viaRemember  : bool
__clone()  : mixed
__wakeup()  : mixed
attempt()  : User
Attempt to authenticate a user using the given credentials.
authenticate()  : mixed
Attempts to authenticate the given user according to the passed credentials.
check()  : bool
Check to see if the user is logged in and activated, and hasn't been banned or suspended.
convertGuestToUser()  : User
Converts a guest user to a registered user.
createThrottleModel()  : Throttle
Creates an instance of the throttle model
createUserModel()  : User
Creates a new instance of the user model
extendUserQuery()  : void
Extend the query used for finding the user.
findGuestUser()  : mixed
findGuestUserByCredentials()  : mixed
findThrottleByLogin()  : Throttle
Find a throttle record by login and ip address
findThrottleByUserId()  : Throttle
Find a throttle record by user id and ip address
findUserByCredentials()  : User
Finds a user by the given credentials.
findUserById()  : mixed
Finds a user by the login value.
findUserByLogin()  : mixed
Finds a user by the login value.
forgetInstance()  : mixed
Forget this singleton's instance if it exists
getImpersonator()  : mixed
Get the original user doing the impersonation
getUser()  : mixed
Returns the current user, if any.
guest()  : bool
Determine if the current user is a guest.
id()  : int|null
Get the ID for the currently authenticated user.
impersonate()  : mixed
Impersonates the given user and sets properties in the session but not the cookie.
init()  : mixed
Initializes the singleton
instance()  : mixed
Create a new instance of this singleton.
isImpersonator()  : bool
Check to see if the current session is being impersonated
login()  : void
Logs in the given user and sets properties in the session.
loginUsingId()  : Authenticatable
Log the given user ID into the application.
logout()  : void
Logs the current user out.
once()  : bool
Log a user into the application without sessions or cookies.
onceUsingId()  : Authenticatable|false
Log the given user ID into the application without sessions or cookies.
register()  : User
Registers a user with the provided credentials with optional flags for activating the newly created user and automatically logging them in
registerGuest()  : User
Registers a guest user by giving the required credentials.
setUser()  : mixed
Sets the user
stopImpersonate()  : mixed
Stop the current session being impersonated and authenticate as the impersonator again
user()  : Authenticatable|null
Get the currently authenticated user.
validate()  : bool
Validate a user's credentials.
viaRemember()  : bool
Determine if the user was authenticated via "remember me" cookie.
__construct()  : mixed
Constructor.
createUserModelQuery()  : Builder
Prepares a query derived from the user model.
validateInternal()  : User
Validate a user's credentials, method used internally.
validateUserModel()  : bool
Perform additional checks on the user model.

Properties

$ipAddress

public string $ipAddress = '0.0.0.0'

The IP address of this request

$groupModel

protected string $groupModel = 'RainLab\User\Models\UserGroup'

User Group Model Class

$requireActivation

protected bool $requireActivation = true

Flag to require users to be activated to login

$sessionKey

protected string $sessionKey = 'user_auth'

Key to store the auth session data in

$throttle

protected array<string|int, mixed> $throttle = []

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

$throttleModel

protected string $throttleModel = 'RainLab\User\Models\Throttle'

Throttle Model Class

$userModel

protected string $userModel = 'RainLab\User\Models\User'

User Model Class

$useSession

protected bool $useSession = true

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

$useThrottle

protected bool $useThrottle = true

Flag to enable login throttling

$viaRemember

protected bool $viaRemember = false

Indicates if the user was authenticated via a recaller cookie.

Methods

__clone()

public __clone() : mixed
Return values
mixed

__wakeup()

public __wakeup() : mixed
Return values
mixed

attempt()

Attempt to authenticate a user using the given credentials.

public attempt([array<string|int, mixed> $credentials = [] ][, bool $remember = false ]) : User
Parameters
$credentials : array<string|int, mixed> = []

The user login details

$remember : bool = false

Store a non-expire cookie for the user

Tags
throws
AuthException

If authentication fails

Return values
User

The successfully logged in user

authenticate()

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

public authenticate(array<string|int, mixed> $credentials[, bool $remember = true ]) : mixed
Parameters
$credentials : array<string|int, mixed>

The user login details

$remember : bool = true

Store a non-expire cookie for the user

Return values
mixed

check()

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

public check() : bool
Return values
bool

convertGuestToUser()

Converts a guest user to a registered user.

public convertGuestToUser(User $user, array<string|int, mixed> $credentials[, bool $activate = false ]) : User
Parameters
$user : User
$credentials : array<string|int, mixed>
$activate : bool = false
Return values
User

createThrottleModel()

Creates an instance of the throttle model

public createThrottleModel() : Throttle
Return values
Throttle

createUserModel()

Creates a new instance of the user model

public createUserModel() : User
Return values
User

extendUserQuery()

Extend the query used for finding the user.

public extendUserQuery(mixed $query) : void
Parameters
$query : mixed
Return values
void

findGuestUser()

public findGuestUser(mixed $email) : mixed
Parameters
$email : mixed
Return values
mixed

findGuestUserByCredentials()

public findGuestUserByCredentials(array<string|int, mixed> $credentials) : mixed
Parameters
$credentials : array<string|int, mixed>
Return values
mixed

findThrottleByLogin()

Find a throttle record by login and ip address

public findThrottleByLogin(string $loginName, string $ipAddress) : Throttle
Parameters
$loginName : string
$ipAddress : string
Return values
Throttle

findThrottleByUserId()

Find a throttle record by user id and ip address

public findThrottleByUserId(int $userId[, string $ipAddress = null ]) : Throttle
Parameters
$userId : int
$ipAddress : string = null
Return values
Throttle

findUserByCredentials()

Finds a user by the given credentials.

public findUserByCredentials(array<string|int, mixed> $credentials) : User
Parameters
$credentials : array<string|int, mixed>

The credentials to find a user by

Tags
throws
AuthException

If the credentials are invalid

Return values
User

The requested user

findUserById()

Finds a user by the login value.

public findUserById(string $id) : mixed
Parameters
$id : string
Return values
mixed

(Models\User || null)

findUserByLogin()

Finds a user by the login value.

public findUserByLogin(string $login) : mixed
Parameters
$login : string
Return values
mixed

(Models\User || null)

forgetInstance()

Forget this singleton's instance if it exists

public final static forgetInstance() : mixed
Return values
mixed

getImpersonator()

Get the original user doing the impersonation

public getImpersonator() : mixed
Return values
mixed

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

getUser()

Returns the current user, if any.

public getUser() : mixed
Return values
mixed

(Models\User || null)

guest()

Determine if the current user is a guest.

public guest() : bool
Return values
bool

id()

Get the ID for the currently authenticated user.

public id() : int|null
Return values
int|null

impersonate()

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

public impersonate(mixed $user) : mixed
Parameters
$user : mixed
Return values
mixed

init()

Initializes the singleton

public init() : mixed
Return values
mixed

instance()

Create a new instance of this singleton.

public final static instance() : mixed
Return values
mixed

isImpersonator()

Check to see if the current session is being impersonated

public isImpersonator() : bool
Return values
bool

login()

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

public login(Authenticatable $user[, mixed $remember = true ]) : void
Parameters
$user : Authenticatable
$remember : mixed = true
Tags
throws
AuthException

If the user is not activated and $this->requireActivation = true

Return values
void

loginUsingId()

Log the given user ID into the application.

public loginUsingId(mixed $id[, bool $remember = false ]) : Authenticatable
Parameters
$id : mixed
$remember : bool = false
Return values
Authenticatable

logout()

Logs the current user out.

public logout() : void
Return values
void

once()

Log a user into the application without sessions or cookies.

public once([array<string|int, mixed> $credentials = [] ]) : bool
Parameters
$credentials : array<string|int, mixed> = []
Return values
bool

onceUsingId()

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

public onceUsingId(mixed $id) : Authenticatable|false
Parameters
$id : mixed
Return values
Authenticatable|false

register()

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

public register(array<string|int, mixed> $credentials[, mixed $activate = false ][, mixed $autoLogin = true ]) : User
Parameters
$credentials : array<string|int, mixed>
$activate : mixed = false
$autoLogin : mixed = true
Return values
User

registerGuest()

Registers a guest user by giving the required credentials.

public registerGuest(array<string|int, mixed> $credentials) : User
Parameters
$credentials : array<string|int, mixed>
Return values
User

stopImpersonate()

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

public stopImpersonate() : mixed
Return values
mixed

validate()

Validate a user's credentials.

public validate([array<string|int, mixed> $credentials = [] ]) : bool
Parameters
$credentials : array<string|int, mixed> = []
Return values
bool

viaRemember()

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

public viaRemember() : bool
Return values
bool

__construct()

Constructor.

protected final __construct() : mixed
Return values
mixed

createUserModelQuery()

Prepares a query derived from the user model.

protected createUserModelQuery() : Builder
Return values
Builder

$query

validateInternal()

Validate a user's credentials, method used internally.

protected validateInternal([array<string|int, mixed> $credentials = [] ]) : User
Parameters
$credentials : array<string|int, mixed> = []
Return values
User

validateUserModel()

Perform additional checks on the user model.

protected validateUserModel( $user) : bool
Parameters
$user :
Return values
bool

Search results