CRUDKit api-doc [Developer]

AuthHelper
in package

Provides functionality for user/permisson handling.

Table of Contents

$callbacks  : array<string|int, callable>
$users  : array<string|int, User>
__construct()  : AuthHelper
Constructor
addUser()  : AuthHelper
Defines a new User.
addUserObject()  : AuthHelper
Defines a new User.
checkAuth()  : mixed
Checks if user is logged in and his permissions to the current page/action.
checkCookies()  : void
Checks if there is cookie data for skin/accent. If yes, override crudkit config.
checkStartpage()  : mixed
getUserId()  : string
Gets the current user id. Returns '' if not logged in.
getUsers()  : array<string|int, CurdkitUser>
Gets all users
isAdmin()  : bool
Checks if the user is an admin user (and if the user is logged in)
isLoggedIn()  : bool
Checks if the user is logged in.
onAfterLogin()  : AuthHelper
Register event handler. Occours after a user has logged in successfully.
triggerEvent()  : mixed
Triggers an event.
userHasAccessTo()  : bool
Checks if a certains user has access to a certain page/action
checkPermissions()  : mixed
loginFailed()  : mixed
performLogin()  : mixed

Properties

$callbacks

private array<string|int, callable> $callbacks = []

Event callback function. [Key => Event name, Value => Callback function ]

Tags
internal

Methods

__construct()

Constructor

public __construct([array<string|int, User$users = [] ]) : AuthHelper
Parameters
$users : array<string|int, User> = []

(optional)

Tags
stackable
Return values
AuthHelper

addUser()

Defines a new User.

public addUser(string $id, string $password[, RestrictionSet $restrictionSet = null ][, Startpage $startpage = null ]) : AuthHelper
Parameters
$id : string

The user ID

$password : string

The password for this user

$restrictionSet : RestrictionSet = null

(optional) The restriction set (permissions) for this user

$startpage : Startpage = null

(optional) The startpage for this user

Tags
stackable
Return values
AuthHelper

checkAuth()

Checks if user is logged in and his permissions to the current page/action.

public checkAuth(string $action, string $pageId[, bool $noPermissionCheck = false ][, bool $loginAttempt = false ]) : mixed
Parameters
$action : string
$pageId : string
$noPermissionCheck : bool = false
$loginAttempt : bool = false
Tags
internal
Return values
mixed

checkCookies()

Checks if there is cookie data for skin/accent. If yes, override crudkit config.

public checkCookies() : void
Return values
void

checkStartpage()

public checkStartpage() : mixed
Tags
internal
Return values
mixed

getUserId()

Gets the current user id. Returns '' if not logged in.

public getUserId() : string
Return values
string

getUsers()

Gets all users

public getUsers() : array<string|int, CurdkitUser>
Return values
array<string|int, CurdkitUser>

isAdmin()

Checks if the user is an admin user (and if the user is logged in)

public isAdmin() : bool
Return values
bool

isLoggedIn()

Checks if the user is logged in.

public isLoggedIn() : bool
Return values
bool

onAfterLogin()

Register event handler. Occours after a user has logged in successfully.

public onAfterLogin(callable $callback) : AuthHelper
$f = function(string $username, bool $isAdmin){...};
authHelper->onAfterLogin($f);
Parameters
$callback : callable

Callback function which is beeing called if this event occours.

Tags
event
stackable
Return values
AuthHelper

triggerEvent()

Triggers an event.

public triggerEvent(string $name) : mixed
Parameters
$name : string

Name of the Event

Tags
internal
Return values
mixed

userHasAccessTo()

Checks if a certains user has access to a certain page/action

public userHasAccessTo(string $action, string $pageId) : bool
Parameters
$action : string

['list', 'card', 'create', 'update', 'delete', 'export', 'chart', '']

$pageId : string
Tags
internal
Return values
bool

checkPermissions()

private checkPermissions(string $action, string $pageId) : mixed
Parameters
$action : string
$pageId : string
Tags
internal
Return values
mixed

loginFailed()

private loginFailed([string $message = '' ]) : mixed
Parameters
$message : string = ''
Tags
internal
Return values
mixed

performLogin()

private performLogin() : mixed
Tags
internal
Return values
mixed

Search results