IAuthenticationService
in
Authentication Service Interface
Defines the contract for authentication services
Table of Contents
Methods
- attempt() : bool
- Attempt to authenticate a user with username and password
- check() : bool
- Check if a user is currently authenticated
- hasRole() : bool
- Check if user has a specific role
- id() : int|null
- Get the currently authenticated user's ID
- isAdmin() : bool
- Check if user is admin
- isAuthorOrHigher() : bool
- Check if user is author or higher
- isEditorOrHigher() : bool
- Check if user is editor or higher
- login() : void
- Log a user in (assumes user is already authenticated)
- loginUsingRememberToken() : bool
- Attempt login using remember token
- logout() : void
- Log the current user out
- setLockoutDuration() : self
- Set lockout duration in minutes
- setMaxLoginAttempts() : self
- Set maximum login attempts before lockout
- user() : User|null
- Get the currently authenticated user
- validateCredentials() : bool
- Validate user credentials
Methods
attempt()
Attempt to authenticate a user with username and password
public
attempt(string $username, string $password[, bool $remember = false ]) : bool
Parameters
- $username : string
- $password : string
- $remember : bool = false
Return values
bool —True if authentication successful
check()
Check if a user is currently authenticated
public
check() : bool
Return values
boolhasRole()
Check if user has a specific role
public
hasRole(string $role) : bool
Parameters
- $role : string
Return values
boolid()
Get the currently authenticated user's ID
public
id() : int|null
Return values
int|nullisAdmin()
Check if user is admin
public
isAdmin() : bool
Return values
boolisAuthorOrHigher()
Check if user is author or higher
public
isAuthorOrHigher() : bool
Return values
boolisEditorOrHigher()
Check if user is editor or higher
public
isEditorOrHigher() : bool
Return values
boollogin()
Log a user in (assumes user is already authenticated)
public
login(User $user[, bool $remember = false ]) : void
Parameters
- $user : User
- $remember : bool = false
loginUsingRememberToken()
Attempt login using remember token
public
loginUsingRememberToken(string $token) : bool
Parameters
- $token : string
Return values
boollogout()
Log the current user out
public
logout() : void
setLockoutDuration()
Set lockout duration in minutes
public
setLockoutDuration(int $lockoutDuration) : self
Parameters
- $lockoutDuration : int
Return values
selfsetMaxLoginAttempts()
Set maximum login attempts before lockout
public
setMaxLoginAttempts(int $maxLoginAttempts) : self
Parameters
- $maxLoginAttempts : int
Return values
selfuser()
Get the currently authenticated user
public
user() : User|null
Return values
User|nullvalidateCredentials()
Validate user credentials
public
validateCredentials(User $user, string $password) : bool
Parameters
- $user : User
- $password : string