October\Rain\Auth\Manager

Source: ~/vendor/october/rain/src/Auth/Manager.php

Authentication manager

Public properties

public string $ipAddress

The IP address of this request

Protected properties

protected Models\User $user

The currently logged in user

protected array $throttle

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

protected string $userModel

User Model Class

protected string $groupModel

User Group Model Class

protected string $throttleModel

Throttle Model Class

protected bool $useThrottle

Flag to enable login throttling

protected bool $requireActivation

Flag to require users to be activated to login

protected string $sessionKey

Key to store the auth session data in

protected static $instance

Public methods

public void __clone()

public void __wakeup()

public Models\User authenticate(array $credentials, bool $remember=true)

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

Parameters
  • array $credentials - The user login details
  • bool $remember - Store a non-expire cookie for the user

public bool check()

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

public Models\Throttle createThrottleModel()

Creates an instance of the throttle model

public Models\User createUserModel()

Creates a new instance of the user model

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

Extend the query used for finding the user.

Parameters

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

Find a throttle record by login and ip address

Parameters
  • string $loginName
  • string $ipAddress

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

Find a throttle record by user id and ip address

Parameters
  • integer $userId
  • string $ipAddress

public Models\User findUserByCredentials(array $credentials)

Finds a user by the given credentials.

Parameters
  • array $credentials - The credentials to find a user by

public mixed findUserById(string $id)

Finds a user by the login value.

Parameters
  • string $id

public mixed findUserByLogin(string $login)

Finds a user by the login value.

Parameters
  • string $login

public static void forgetInstance()

Forget this singleton's instance if it exists

public mixed getImpersonator()

Get the original user doing the impersonation

public mixed getUser()

Returns the current user, if any.

public void impersonate($user)

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

Parameters
  • $user

public static void instance()

Create a new instance of this singleton.

public bool isImpersonator()

Check to see if the current session is being impersonated

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

Logs in the given user and sets properties in the session

Parameters
  • $user
  • $remember

public void logout()

Logs the current user out.

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

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

Parameters
  • array $credentials
  • bool $activate
  • bool $autoLogin

public void setUser($user)

Sets the user

Parameters
  • $user

public void stopImpersonate()

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

Protected methods

protected void __construct()

Constructor.

protected October\Rain\Database\Builder createUserModelQuery()

Prepares a query derived from the user model.

protected void init()

Initializes the singleton