Menu

## AuthHelper
in package

AuthHelper.php : 8

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

AuthHelper.php : 20
`private array<string|int, callable> $callbacks = []`

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

##### Tags

internal

#### $users

AuthHelper.php : 14
`private array<string|int, User> $users = []`

##### Tags

internal

### Methods

#### __construct()

AuthHelper.php : 29

Constructor

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

##### Parameters

$users : array<string|int, User> = []

  (optional)

##### Tags

stackable

##### Return values

AuthHelper —

#### addUser()

AuthHelper.php : 75

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 —

#### addUserObject()

AuthHelper.php : 50

Defines a new User.

`public addUserObject(User $user) : AuthHelper`

##### Parameters

$user : User

  The user Object.

##### Tags

stackable

##### Return values

AuthHelper —

#### checkAuth()

AuthHelper.php : 224

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()

AuthHelper.php : 202

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

`public checkCookies() : void`

##### Return values

void —

#### checkStartpage()

AuthHelper.php : 172
`public checkStartpage() : mixed`

##### Tags

internal

##### Return values

mixed —

#### getUserId()

AuthHelper.php : 129

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

`public getUserId() : string`

##### Return values

string —

#### getUsers()

AuthHelper.php : 60

Gets all users

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

##### Return values

array<string|int, CurdkitUser> —

#### isAdmin()

AuthHelper.php : 119

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

`public isAdmin() : bool`

##### Return values

bool —

#### isLoggedIn()

AuthHelper.php : 109

Checks if the user is logged in.

`public isLoggedIn() : bool`

##### Return values

bool —

#### onAfterLogin()

AuthHelper.php : 147

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()

AuthHelper.php : 158

Triggers an event.

`public triggerEvent(string $name) : mixed`

##### Parameters

$name : string

  Name of the Event

##### Tags

internal

##### Return values

mixed —

#### userHasAccessTo()

AuthHelper.php : 87

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()

AuthHelper.php : 270
`private checkPermissions(string $action, string $pageId) : mixed`

##### Parameters

$action : string
$pageId : string

##### Tags

internal

##### Return values

mixed —

#### loginFailed()

AuthHelper.php : 261
`private loginFailed([string $message = '' ]) : mixed`

##### Parameters

$message : string = ''

##### Tags

internal

##### Return values

mixed —

#### performLogin()

AuthHelper.php : 287
`private performLogin() : mixed`

##### Tags

internal

##### Return values

mixed —

## Search results