Neuron-PHP

Authentication
in package
implements IAuthenticationService

Authentication service.

Handles user authentication, session management, and remember me functionality.

Table of Contents

Interfaces

IAuthenticationService
Authentication Service Interface

Properties

$_lockoutDuration  : int
$_maxLoginAttempts  : int
$_passwordHasher  : PasswordHasher
$_sessionManager  : SessionManager
$_userRepository  : IUserRepository

Methods

__construct()  : mixed
attempt()  : bool
Attempt to authenticate a user
check()  : bool
Check if a user is authenticated
hasRole()  : bool
Check if user has a specific role
id()  : int|null
Get the current 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
loginUsingRememberToken()  : bool
Attempt to log in 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
setRememberToken()  : void
Set remember me token for user

Properties

Methods

attempt()

Attempt to authenticate a user

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 authenticated

public check() : bool
Return values
bool

hasRole()

Check if user has a specific role

public hasRole(string $role) : bool
Parameters
$role : string
Return values
bool

id()

Get the current user's ID

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

isAdmin()

Check if user is admin

public isAdmin() : bool
Return values
bool

isAuthorOrHigher()

Check if user is author or higher

public isAuthorOrHigher() : bool
Return values
bool

isEditorOrHigher()

Check if user is editor or higher

public isEditorOrHigher() : bool
Return values
bool

login()

Log a user in

public login(User $user[, bool $remember = false ]) : void
Parameters
$user : User
$remember : bool = false

loginUsingRememberToken()

Attempt to log in using remember token

public loginUsingRememberToken(string $token) : bool
Parameters
$token : string
Return values
bool

setLockoutDuration()

Set lockout duration in minutes

public setLockoutDuration(int $lockoutDuration) : self
Parameters
$lockoutDuration : int
Return values
self

setMaxLoginAttempts()

Set maximum login attempts before lockout

public setMaxLoginAttempts(int $maxLoginAttempts) : self
Parameters
$maxLoginAttempts : int
Return values
self

validateCredentials()

Validate user credentials

public validateCredentials(User $user, string $password) : bool
Parameters
$user : User
$password : string
Return values
bool

setRememberToken()

Set remember me token for user

private setRememberToken(User $user) : void
Parameters
$user : User

        
On this page

Search results