Documentation

CoreUser
in package

$this->core->user Class to manage User information

Table of Contents

Constants

APIPortalServices  = 'https://api.cloudframework.io/erp/portal-users/2.0'
APIServices  = 'https://api.cloudframework.io/core/signin'

Properties

$activeTokens  : int
$cached  : bool
$data  : mixed
$error  : mixed
$errorCode  : mixed
$errorMsg  : mixed
$expirationTime  : int
$id  : mixed
$isAuth  : mixed
$maxTokens  : int
$namespace  : mixed
$token  : mixed
$tokenExpiration  : mixed
$core  : mixed

Methods

__construct()  : mixed
addError()  : mixed
Add an error Message
addUserData()  : void
Add Info to User data and try to store it in cache
checkERPToken()  : void
Use checkPlatformToken
checkPlatformToken()  : false|void
Verify that a token is valid and update the following properties: namespace, userId, userData It allows to work with several active tokens at the same time
checkUserToken()  : bool|void
Check a token previously generated
checkWebToken()  : false|void
Verify that a token is valid and update the following properties: namespace, userId, userData It allows to work with several active tokens at the same time
createUserToken()  : string
Return a Token with a specific format token__{user}__{namespace}__hash() This method is to be used together with setAuth(..)
getDateTime()  : string
Get datetime Y-m-d H:i:s converted to User TimeZone
getLang()  : string
Get a user lang. 'en' default
getLicenses()  : bool
Set a privilege for a user
getPrivileges()  : bool
Set a privilege for a user
getTimeZone()  : string
Get de TimeZone of the user. UTC by default
hasLicense()  : bool
Tell if the user has specific license
hasPrivilege()  : bool
Tell if the user has specific privilege
isAuth()  : bool
Return if the user is Authenticated
isPortalUser()  : string
Get a user lang. 'en' default
loginCloudPlatform()  : bool|void
Execute a sign-in over the CLOUD-PLATFORM using $user/$password in $platform_id and store the token and user info in $this->token, $this->data
loginERP()  : bool|void
Deprecated. Use loginCloudPlatform
logoutERPToken()  : bool
Logout the user
logoutUserToken()  : bool
Logout the user
reset()  : mixed
Resent user variables
setAuth()  : mixed
Set Auth for a user in a namespace and store the result in cache for new queries
setLang()  : mixed
Set a lang for a user
setLicense()  : mixed
Set a license for a user
setPrivilege()  : mixed
Set a privilege for a user
unsetLicense()  : mixed
Unset a license for a user
unsetPrivilege()  : mixed
Unset a privilege for a user
updateERPUserDataInCache()  : true|null
Update UserData in cache and in the Token of the user

Constants

APIPortalServices

public mixed APIPortalServices = 'https://api.cloudframework.io/erp/portal-users/2.0'

APIServices

public mixed APIServices = 'https://api.cloudframework.io/core/signin'

Properties

$activeTokens

public int $activeTokens = 0

Number of tokens active for the user

$cached

public bool $cached = \false

says if the user data has been retrieved from cache

$data

public mixed $data = []

$error

public mixed $error = \false

$errorCode

public mixed $errorCode = \null

$errorMsg

public mixed $errorMsg = []

$expirationTime

public int $expirationTime = 3600

Time to expire a token

$isAuth

public mixed $isAuth = \false

$maxTokens

public int $maxTokens = 10

Max number of tokens in $expirationTime to handle

$namespace

public mixed $namespace = 'Default'

$token

public mixed $token

$tokenExpiration

public mixed $tokenExpiration

Methods

__construct()

public __construct(Core7 &$core) : mixed
Parameters
$core : Core7

addError()

Add an error Message

public addError( $code, null $message) : mixed
Parameters
$code :
$message : null

addUserData()

Add Info to User data and try to store it in cache

public addUserData(string $key, mix $data) : void
Parameters
$key : string

Key name for the array of user data

$data : mix

data to store

checkERPToken()

Use checkPlatformToken

public checkERPToken(string $token, string $integration_key[, bool $refresh = false ]) : void
Parameters
$token : string
$integration_key : string
$refresh : bool = false
Tags
deprecated

checkPlatformToken()

Verify that a token is valid and update the following properties: namespace, userId, userData It allows to work with several active tokens at the same time

public checkPlatformToken(string $token, string $integration_key[, bool $refresh = false ]) : false|void
Parameters
$token : string

Token to verify with CloudFramework ERP

$integration_key : string

Integration Key to call CloudFramework API for signing

$refresh : bool = false

if true it ignores cached data and call CLOUD-DIRECTORY API

Return values
false|void

checkUserToken()

Check a token previously generated

public checkUserToken(string $token) : bool|void
Parameters
$token : string
Return values
bool|void

checkWebToken()

Verify that a token is valid and update the following properties: namespace, userId, userData It allows to work with several active tokens at the same time

public checkWebToken(string $token, string $integration_key[, bool $refresh = false ]) : false|void
Parameters
$token : string

Token to verify with CloudFramework ERP

$integration_key : string

Integration Key to call CloudFramework API for signing

$refresh : bool = false

indicates if we have to ignore cached data with $refresh=true. Default is false

Return values
false|void

createUserToken()

Return a Token with a specific format token__{user}__{namespace}__hash() This method is to be used together with setAuth(..)

public createUserToken( $user[,  $namespace = 'default' ][, mixed $data = null ]) : string
Parameters
$user :
$namespace : = 'default'
$data : mixed = null
Return values
string

getDateTime()

Get datetime Y-m-d H:i:s converted to User TimeZone

public getDateTime([string $time_zone = '' ][, string $date_time = '' ]) : string
Parameters
$time_zone : string = ''
$date_time : string = ''
Return values
string

getLang()

Get a user lang. 'en' default

public getLang() : string
Return values
string

getLicenses()

Set a privilege for a user

public getLicenses() : bool
Return values
bool

getPrivileges()

Set a privilege for a user

public getPrivileges() : bool
Return values
bool

getTimeZone()

Get de TimeZone of the user. UTC by default

public getTimeZone() : string
Return values
string

hasLicense()

Tell if the user has specific license

public hasLicense(string $license) : bool
Parameters
$license : string
Return values
bool

hasPrivilege()

Tell if the user has specific privilege

public hasPrivilege(string $privilege) : bool
Parameters
$privilege : string
Return values
bool

isAuth()

Return if the user is Authenticated

public isAuth() : bool
Return values
bool

isPortalUser()

Get a user lang. 'en' default

public isPortalUser() : string
Return values
string

loginCloudPlatform()

Execute a sign-in over the CLOUD-PLATFORM using $user/$password in $platform_id and store the token and user info in $this->token, $this->data

public loginCloudPlatform(string $user, string $password, string $platform_id, string $integration_key) : bool|void
Parameters
$user : string
$password : string
$platform_id : string
$integration_key : string
Return values
bool|void

loginERP()

Deprecated. Use loginCloudPlatform

public loginERP( $user,  $password,  $namespace,  $integration_key) : bool|void
Parameters
$user :
$password :
$namespace :
$integration_key :
Tags
deprecated
Return values
bool|void

logoutERPToken()

Logout the user

public logoutERPToken([string $token = '' ][, string $delete_all_tokens = false ]) : bool
Parameters
$token : string = ''
$delete_all_tokens : string = false
Return values
bool

logoutUserToken()

Logout the user

public logoutUserToken([string $token = '' ][, string $delete_all_tokens = false ]) : bool
Parameters
$token : string = ''
$delete_all_tokens : string = false
Return values
bool

reset()

Resent user variables

public reset() : mixed

setAuth()

Set Auth for a user in a namespace and store the result in cache for new queries

public setAuth(bool $auth[, string $user = '' ][, string $namespace = '' ][, string $token = '' ][, array<string|int, mixed> $data = null ]) : mixed
Parameters
$auth : bool
$user : string = ''
$namespace : string = ''
$token : string = ''
$data : array<string|int, mixed> = null

setLang()

Set a lang for a user

public setLang(string $lang) : mixed
Parameters
$lang : string

setLicense()

Set a license for a user

public setLicense( $license[, bool $active = true ]) : mixed
Parameters
$license :
$active : bool = true

setPrivilege()

Set a privilege for a user

public setPrivilege( $privilege[, bool $active = true ]) : mixed
Parameters
$privilege :
$active : bool = true

unsetLicense()

Unset a license for a user

public unsetLicense( $license) : mixed
Parameters
$license :

unsetPrivilege()

Unset a privilege for a user

public unsetPrivilege( $privilege) : mixed
Parameters
$privilege :

updateERPUserDataInCache()

Update UserData in cache and in the Token of the user

public updateERPUserDataInCache() : true|null
Return values
true|null

        
On this page

Search results