Documentation

Authentication
in package

Table of Contents

Constants

CREDENTIALS_FILE  = __DIR__ . "/credentials.env"

Properties

$adminPasswordHash  : string|null

Methods

__construct()  : mixed
isLoggedIn()  : bool
isNeedInit()  : bool
check if password is set
logIn()  : void
On invalid password die with 401 http code, on valid, set "loggedIn" session field to true
logOut()  : void
destroy session
register()  : void
set password and "loggedIn" session field to true
createCredentialsFileIfAbsent()  : void
getAdminCredential()  : void
read password hash from credentials.env, if absent, set to adminPasswordHash field null
setAdminCredential()  : void
reset password hash to credentials.env
setPassword()  : void
hash password and puts it into credentials.env file

Constants

CREDENTIALS_FILE

private mixed CREDENTIALS_FILE = __DIR__ . "/credentials.env"

Properties

$adminPasswordHash

private string|null $adminPasswordHash = null

Methods

isNeedInit()

check if password is set

public isNeedInit() : bool
Return values
bool

logIn()

On invalid password die with 401 http code, on valid, set "loggedIn" session field to true

public logIn(string $password) : void
Parameters
$password : string

register()

set password and "loggedIn" session field to true

public register(string $password) : void
Parameters
$password : string

createCredentialsFileIfAbsent()

private createCredentialsFileIfAbsent() : void

getAdminCredential()

read password hash from credentials.env, if absent, set to adminPasswordHash field null

private getAdminCredential() : void

setAdminCredential()

reset password hash to credentials.env

private setAdminCredential() : void

setPassword()

hash password and puts it into credentials.env file

private setPassword(string $password) : void
Parameters
$password : string

        
On this page

Search results