October\Rain\Auth\Manager

Overview

Manager for authentication

Implements
  • Illuminate\Contracts\Auth\StatefulGuard
  • Illuminate\Contracts\Auth\Guard

Public Properties

public string $ipAddress

ipAddress of this request.

Protected Properties

protected Models\User $user

user that is currently logged in

protected array $throttle

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

protected string $userModel

userModel class

protected string $roleModel

roleModel class

protected string $groupModel

groupModel class

protected string $throttleModel

throttleModel class

protected bool $useThrottle

useThrottle flag to enable login throttling.

protected bool $useRehash

useRehash flag to enable password rehashing.

protected bool $useSession

useSession internal flag to toggle using the session for the current authentication request.

protected bool $requireActivation

requireActivation rlag to require users to be activated to login.

protected string $sessionKey

sessionKey to store the auth session data in.

protected bool $viaRemember

viaRemember indicates if the user was authenticated via a recaller cookie.

protected bool|null $checkCache

checkCache adds a specific cache to the check() method to reduce the number of database calls.

protected static ?static $instance


Public Methods

public attempt()

public attempt(
    array $credentials = [],
    bool $remember = false
): Models\User 

attempt to authenticate a user using the given credentials.

public authenticate()

public authenticate($credentials, $remember = true): void

authenticate the given user according to the passed credentials

public check()

public check(): bool 

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

public clearThrottleForUserId()

public clearThrottleForUserId($userId): void

clearThrottleForUserId unsuspends and clears all throttles records for a user

public createRoleModel()

public createRoleModel(): Models\Role 

createRoleModel creates an instance of the role model.

public createThrottleModel()

public createThrottleModel(): Models\Throttle 

createThrottleModel creates an instance of the throttle model.

public createUserModel()

public createUserModel(): void

createUserModel instance

public extendUserQuery()

public extendUserQuery(October\Rain\Database\Builder $query): void

extendUserQuery used for finding the user.

public findThrottleByLogin()

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

findThrottleByLogin and ip address

public findThrottleByUserId()

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

findThrottleByUserId and ip address

public findUserByCredentials()

public findUserByCredentials(array $credentials): Models\User 

findUserByCredentials finds a user by the given credentials.

public findUserById()

public findUserById(string $id): Authenticatable|null 

findUserById finds a user by the login value.

public findUserByLogin()

public findUserByLogin(string $login): Authenticatable|null 

findUserByLogin finds a user by the login value.

public static forgetInstance()

public static forgetInstance(): void

forgetInstance if it exists

public getImpersonator()

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

getImpersonator gets the original user doing the impersonation

public getModel()

public getModel(): void

getModel returns the class name for the user model

public getProvider()

public getProvider(): void

getProvider just passes it back to the current class

public getRealUser()

public getRealUser(): Authenticatable|null 

getRealUser gets the "real" user to bypass impersonation.

public getUser()

public getUser(): Authenticatable|null 

getUser returns the current user, if any.

public guest()

public guest(): bool 

guest determines if the current user is a guest.

public hasRemember()

public hasRemember(): bool 

hasRemember returns true if the user requested to stay logged in.

public hasSession()

public hasSession(): bool 

hasSession returns true if a user session exists without verifying it.

public hasUser()

public hasUser(): bool 

hasUser determines if the guard has a user instance.

public id()

public id(): int|null 

id for the currently authenticated user.

public impersonate()

public impersonate($user): void

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

public impersonateRole()

public impersonateRole($role): void

impersonateRole will impersonate a role for the current user

public static instance()

public static instance(): void

instance create a new instance of this singleton

public isImpersonator()

public isImpersonator(): bool 

isImpersonator checks to see if the current session is being impersonated.

public isRoleImpersonator()

public isRoleImpersonator(): bool 

public login()

public login($user, $remember = true): void

login the given user and sets properties in the session.

public loginUsingId()

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

loginUsingId logs the given user ID into the application.

public logout()

public logout(): void

logout logs the current user out.

public once()

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

once logs a user into the application without sessions or cookies.

public onceUsingId()

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

onceUsingId logs the given user ID into the application without sessions or cookies.

public register()

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

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

public setUser()

public setUser($user): void

setUser will set the current user.

public stopImpersonate()

public stopImpersonate(): void

stopImpersonate stops the current session being impersonated and attempts to authenticate as the impersonator again.

public stopImpersonateRole()

public stopImpersonateRole(): void

stopImpersonateRole will stop role impersonation

public user()

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

user will return the currently authenticated user.

public validate()

public validate($credentials = []): bool 

validate a user's credentials.

public viaRemember()

public viaRemember(): bool 

viaRemember determines if the user was authenticated via "remember me" cookie.

Protected Methods

protected __construct()

protected __construct(): void

protected applyRoleImpersonation()

protected applyRoleImpersonation($user): void

applyRoleImpersonation tells the user model to impersonate the role

protected createUserModelQuery()

protected createUserModelQuery(): October\Rain\Database\Builder 

createUserModelQuery prepares a query derived from the user model.

protected getPersistCodeFromSession()

protected getPersistCodeFromSession($isChecking = true): array|null 

getPersistCodeFromSession will return the user ID and persist token from the session. The resulting array will contain the user ID and persistence code [id, code] or null.

protected init()

protected init(): void

init the singleton

protected setPersistCodeToSession()

protected setPersistCodeToSession(
    $user,
    $remember = true,
    $impersonating = false
): void

setPersistCodeToSession stores the user persistence in the session and cookie.

protected validateInternal()

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

validateInternal a user's credentials, method used internally.

protected validateUserModel()

protected validateUserModel(object $user): bool 

validateUserModel perform additional checks on the user model.