Neuron-PHP

helpers.php

Authentication helper functions.

Provides convenient access to authentication functionality.

Table of Contents

Functions

auth()  : User|null
Get the authenticated user
user()  : User|null
Alias for auth()
user_id()  : int|null
Get the authenticated user's ID
is_logged_in()  : bool
Check if user is authenticated
is_guest()  : bool
Check if user is a guest (not authenticated)
is_admin()  : bool
Check if user is an admin
is_editor()  : bool
Check if user is an editor
is_author()  : bool
Check if user is an author
has_role()  : bool
Check if user has a specific role
csrf_token()  : string
Get the current CSRF token
csrf_field()  : string
Generate a CSRF token hidden input field
current_user_identifier()  : string
Get current user identifier for audit purposes

Functions

auth()

Get the authenticated user

auth() : User|null
Return values
User|null

user_id()

Get the authenticated user's ID

user_id() : int|null
Return values
int|null

is_logged_in()

Check if user is authenticated

is_logged_in() : bool
Return values
bool

is_guest()

Check if user is a guest (not authenticated)

is_guest() : bool
Return values
bool

is_admin()

Check if user is an admin

is_admin() : bool
Return values
bool

is_editor()

Check if user is an editor

is_editor() : bool
Return values
bool

is_author()

Check if user is an author

is_author() : bool
Return values
bool

has_role()

Check if user has a specific role

has_role(string $role) : bool
Parameters
$role : string
Return values
bool

csrf_token()

Get the current CSRF token

csrf_token() : string
Return values
string

csrf_field()

Generate a CSRF token hidden input field

csrf_field() : string
Return values
string

current_user_identifier()

Get current user identifier for audit purposes

current_user_identifier() : string

Returns the authenticated CMS user's username if available (web context), otherwise returns the OS user running the process (CLI context).

Return values
string

User identifier (e.g., "admin" or "www-data" or "system")


        
On this page

Search results