Dotclear 2.24
Loading...
Searching...
No Matches
dcAuth Class Reference

Public Member Functions

 __construct ()
 
Credentials and user permissions
 checkUser (string $user_id, ?string $pwd=null, ?string $user_key=null, bool $check_blog=true)
 
 crypt (string $pwd)
 
 cryptLegacy (string $pwd)
 
 checkPassword (string $pwd)
 
 sessionExists ()
 
 checkSession (?string $uid=null)
 
 mustChangePassword ()
 
 isSuperAdmin ()
 
 check (?string $permissions, ?string $blog_id)
 
 allowPassChange ()
 
Sudo
 sudo ($fn,... $args)
 
User information and options
 getPermissions (?string $blog_id)
 
 getBlogCount ()
 
 findUserBlog (?string $blog_id=null)
 
 userID ()
 
 getInfo ($information)
 
 getOption ($option)
 
 getOptions ()
 
Permissions
 parsePermissions ($level)
 
 makePermissions ($list)
 
 getPermissionsTypes ()
 
 setPermissionType (string $name, string $title)
 
Password recovery
 setRecoverKey (string $user_id, string $user_email)
 
 recoverUserPassword (string $recover_key)
 

Data Fields

const USER_TABLE_NAME = 'user'
 
const PERMISSIONS_TABLE_NAME = 'permissions'
 
const PERMISSION_ADMIN = 'admin'
 
const PERMISSION_CONTENT_ADMIN = 'contentadmin'
 
const PERMISSION_USAGE = 'usage'
 
const PERMISSION_PUBLISH = 'publish'
 
const PERMISSION_DELETE = 'delete'
 
const PERMISSION_CATEGORIES = 'categories'
 
const PERMISSION_MEDIA_ADMIN = 'media_admin'
 
const PERMISSION_MEDIA = 'media'
 
 $blog_count = null
 
 $user_prefs
 

Protected Attributes

 $con
 
 $user_table
 
 $perm_table
 
 $blog_table
 
 $user_id
 
 $user_info = []
 
 $user_options = []
 
 $user_change_pwd
 
 $user_admin
 
 $permissions = []
 
 $allow_pass_change = true
 
 $blogs = []
 
 $perm_types
 

Constructor & Destructor Documentation

◆ __construct()

__construct ( )

Class constructor. Takes dcCore object as single argument.

References dcCore\app(), dcBlog\BLOG_TABLE_NAME, PERMISSIONS_TABLE_NAME, and USER_TABLE_NAME.

Member Function Documentation

◆ checkUser()

checkUser ( string  $user_id,
?string  $pwd = null,
?string  $user_key = null,
bool  $check_blog = true 
)

Checks if user exists and can log in. $pwd argument is optionnal while you may need to check user without password. This method will create credentials and populate all needed object properties.

Parameters
string$user_idUser ID
string$pwdUser password
string$user_keyUser key check
boolean$check_blogChecks if user is associated to a blog or not.
Returns
bool

References $ret, $user_id, dcCore\app(), http\browserUID(), DC_CRYPT_ALGO, DC_MASTER_KEY, findUserBlog(), dcUtils\getUserCN(), crypt\hmac(), and dcSqlStatement\where().

Referenced by checkSession().

◆ crypt()

crypt ( string  $pwd)

This method crypt given string (password, session_id, …).

Parameters
string$pwdString to be crypted
Returns
string crypted value

◆ cryptLegacy()

cryptLegacy ( string  $pwd)

This method crypt given string (password, session_id, …).

Parameters
string$pwdString to be crypted
Returns
string crypted value

References DC_CRYPT_ALGO, DC_MASTER_KEY, and crypt\hmac().

◆ checkPassword()

checkPassword ( string  $pwd)

This method only check current user password.

Parameters
string$pwdUser password
Returns
bool

◆ sessionExists()

sessionExists ( )

This method checks if user session cookie exists

Returns
bool

References DC_SESSION_NAME.

◆ checkSession()

checkSession ( ?string  $uid = null)

This method checks user session validity.

Parameters
string$uidBrowser UID
Returns
bool

References dcCore\app(), http\browserUID(), checkUser(), DC_MASTER_KEY, and userID().

◆ mustChangePassword()

mustChangePassword ( )

Checks if user must change his password in order to login.

Returns
bool

References $user_change_pwd.

◆ isSuperAdmin()

isSuperAdmin ( )

Checks if user is super admin

Returns
bool

References $user_admin.

◆ check()

check ( ?string  $permissions,
?string  $blog_id 
)

Checks if user has permissions given in $permissions for blog $blog_id.

Parameters
string$permissionsPermissions list (comma separated)
string$blog_idBlog ID
Returns
bool

References $permissions, and getPermissions().

◆ allowPassChange()

allowPassChange ( )

Returns true if user is allowed to change its password.

Returns
bool

References $allow_pass_change.

◆ sudo()

sudo (   $fn,
  $args 
)

Calls $fn function with super admin rights and returns the function result.

Parameters
callable | array$fnCallback function
Returns
mixed

◆ getPermissions()

getPermissions ( ?string  $blog_id)

Returns user permissions for a blog as an array which looks like:

  • [blog_id]
    • [permission] => true
    • ...
Parameters
string$blog_idBlog ID
Returns
false|array

References parsePermissions().

Referenced by check(), and findUserBlog().

◆ getBlogCount()

getBlogCount ( )

Gets the blog count.

Returns
int The blog count.

References $blog_count, and dcCore\app().

◆ findUserBlog()

findUserBlog ( ?string  $blog_id = null)

Finds an user blog.

Parameters
string$blog_idThe blog identifier
Returns
mixed

References dcBlog\BLOG_OFFLINE, and getPermissions().

Referenced by checkUser().

◆ userID()

userID ( )

Returns current user ID

Returns
null|mixed

References $user_id.

Referenced by checkSession().

◆ getInfo()

getInfo (   $information)

Returns information about a user .

Parameters
string$informationInformation name
Returns
mixed

◆ getOption()

getOption (   $option)

Returns a specific user option

Parameters
string$optionOption name
Returns
mixed

◆ getOptions()

getOptions ( )

Returns all user options in an associative array.

Returns
array

References $user_options.

◆ parsePermissions()

parsePermissions (   $level)

Returns an array with permissions parsed from the string $level

Parameters
string$levelPermissions string
Returns
array

Referenced by getPermissions().

◆ makePermissions()

makePermissions (   $list)

Makes permissions string from an array.

Parameters
array$listThe list
Returns
string

◆ getPermissionsTypes()

getPermissionsTypes ( )

Returns perm_types property content.

Returns
array

References $perm_types.

◆ setPermissionType()

setPermissionType ( string  $name,
string  $title 
)

Adds a new permission type.

Parameters
string$namePermission name
string$titlePermission title

◆ setRecoverKey()

setRecoverKey ( string  $user_id,
string  $user_email 
)

Add a recover key to a specific user identified by its email and password.

Parameters
string$user_idUser ID
string$user_emailUser Email
Returns
string

References $user_id.

◆ recoverUserPassword()

recoverUserPassword ( string  $recover_key)

Creates a new user password using recovery key. Returns an array:

  • user_email
  • user_id
  • new_pass
Parameters
string$recover_keyRecovery key
Returns
array

References crypt\createPassword().

Field Documentation

◆ USER_TABLE_NAME

◆ PERMISSIONS_TABLE_NAME

◆ PERMISSION_ADMIN

◆ PERMISSION_CONTENT_ADMIN

◆ PERMISSION_USAGE

◆ PERMISSION_PUBLISH

◆ PERMISSION_DELETE

◆ PERMISSION_CATEGORIES

◆ PERMISSION_MEDIA_ADMIN

◆ PERMISSION_MEDIA

◆ $con

$con
protected

◆ $user_table

$user_table
protected

◆ $perm_table

$perm_table
protected

◆ $blog_table

$blog_table
protected

◆ $user_id

$user_id
protected

Referenced by checkUser(), setRecoverKey(), and userID().

◆ $user_info

$user_info = []
protected

◆ $user_options

$user_options = []
protected

Referenced by getOptions().

◆ $user_change_pwd

$user_change_pwd
protected

Referenced by mustChangePassword().

◆ $user_admin

$user_admin
protected

Referenced by isSuperAdmin().

◆ $permissions

$permissions = []
protected

Referenced by check().

◆ $allow_pass_change

$allow_pass_change = true
protected

Referenced by allowPassChange().

◆ $blogs

$blogs = []
protected

◆ $blog_count

$blog_count = null

Referenced by getBlogCount().

◆ $perm_types

$perm_types
protected

Referenced by getPermissionsTypes().

◆ $user_prefs

$user_prefs

The documentation for this class was generated from the following file: