Methods summary
public
integer|null
|
#
GetId( )
User unique id, representing primary key in database
or sequence number in system config.
Example: 0 | 1 | 2...
User unique id, representing primary key in database
or sequence number in system config.
Example: 0 | 1 | 2...
Returns
integer|null
|
public
MvcCore\Ext\Auths\Basics\User
|
#
SetId( integer|null $id )
Set user unique id, representing primary key in database
or sequence number in system config.
Example: 0 | 1 | 2...
Set user unique id, representing primary key in database
or sequence number in system config.
Example: 0 | 1 | 2...
Parameters
Returns
|
public
boolean
|
#
IsActive( )
Get user active state boolean. TRUE for active, FALSE otherwise.
This function is only alias for $user->GetActive(); .
Get user active state boolean. TRUE for active, FALSE otherwise.
This function is only alias for $user->GetActive(); .
Returns
boolean
|
public
boolean
|
#
GetActive( )
Get user active state boolean. TRUE for active, FALSE otherwise.
Get user active state boolean. TRUE for active, FALSE otherwise.
Returns
boolean
|
public
MvcCore\Ext\Auths\Basics\User
|
#
SetActive( $active )
Set user active state boolean. TRUE for active, FALSE otherwise.
Set user active state boolean. TRUE for active, FALSE otherwise.
Returns
|
public
|
#
GetUserName( )
Unique user name to log in. It could be email,
unique user name or anything uniquelse.
Example: "admin" | "john" | "tomflidr@gmail.com"
Unique user name to log in. It could be email,
unique user name or anything uniquelse.
Example: "admin" | "john" | "tomflidr@gmail.com"
Var
string
|
public
MvcCore\Ext\Auths\Basics\User
|
#
SetUserName( string $userName )
Set unique user name to log in. It could be email,
unique user name or anything uniquelse.
Example: "admin" | "john" | "tomflidr@gmail.com"
Set unique user name to log in. It could be email,
unique user name or anything uniquelse.
Example: "admin" | "john" | "tomflidr@gmail.com"
Parameters
Returns
|
public
|
#
GetFullName( )
User full name string to display in application
for authenticated user at sign out button.
Example: "Administrator" | "John" | "Tom Flidr"
User full name string to display in application
for authenticated user at sign out button.
Example: "Administrator" | "John" | "Tom Flidr"
Var
string
|
public
MvcCore\Ext\Auths\Basics\User
|
#
SetFullName( string $fullName )
Set user full name string to display in application
for authenticated user at sign out button.
Example: "Administrator" | "John" | "Tom"
Set user full name string to display in application
for authenticated user at sign out button.
Example: "Administrator" | "John" | "Tom"
Parameters
Returns
|
public
|
#
GetPasswordHash( )
Password hash, usually NULL . It exists only for authentication moment.
From moment, when is user instance loaded with password hash by session username to
moment, when is compared hashed sent password and stored password hash.
After password hashes comparison, password hash is un-setted.
Password hash, usually NULL . It exists only for authentication moment.
From moment, when is user instance loaded with password hash by session username to
moment, when is compared hashed sent password and stored password hash.
After password hashes comparison, password hash is un-setted.
Var
string|NULL
|
public
MvcCore\Ext\Auths\Basics\User
|
#
SetPasswordHash( string|null $passwordHash )
Set password hash, usually NULL . It exists only for authentication moment.
From moment, when is user instance loaded with password hash by session username to
moment, when is compared hashed sent password and stored password hash.
After password hashes comparison, password hash is un-setted.
Set password hash, usually NULL . It exists only for authentication moment.
From moment, when is user instance loaded with password hash by session username to
moment, when is compared hashed sent password and stored password hash.
After password hashes comparison, password hash is un-setted.
Parameters
Returns
|
public static
MvcCore\Ext\Auths\Basics\User |null
|
#
SetUpUserBySession( )
Try to get user model instance from application users list
(it could be database table or system config) by user session namespace
userName record if authenticated boolean in user session namespace is TRUE .
Or return NULL for no user by user session namespace records.
Try to get user model instance from application users list
(it could be database table or system config) by user session namespace
userName record if authenticated boolean in user session namespace is TRUE .
Or return NULL for no user by user session namespace records.
Returns
|
public static
MvcCore\Ext\Auths\Basics\User |null
|
#
LogIn( string $userName = '', string $password = '' )
Try to get user model instance from application users list
(it could be database table or system config) by submitted
and cleaned $userName , hash submitted and cleaned $password and try to compare
hashed submitted password and user password hash from application users
list. If password hashes are the same, set username and authenticated boolean
into user session namespace. Then user is logged in.
Try to get user model instance from application users list
(it could be database table or system config) by submitted
and cleaned $userName , hash submitted and cleaned $password and try to compare
hashed submitted password and user password hash from application users
list. If password hashes are the same, set username and authenticated boolean
into user session namespace. Then user is logged in.
Parameters
- $userName
- Submitted and cleaned username. Characters
' " < > \ = ^ | & ~are automatically encoded to html entities by default \MvcCore\Ext\Auths\Basic` sign in form.
- $password
- Submitted and cleaned password. Characters
' " < > \ = ^ | & ~are automatically encoded to html entities by default \MvcCore\Ext\Auths\Basic` sign in form.
Returns
|
public static
|
#
LogOut( boolean $destroyWholeSession = FALSE )
Log out user. Set authenticated record in user session namespace to FALSE
by default. User name should still remain in user session namespace.
If First argument $destroyWholeSession is TRUE , destroy whole
user session namespace with authenticated bool and with userName string record.
Log out user. Set authenticated record in user session namespace to FALSE
by default. User name should still remain in user session namespace.
If First argument $destroyWholeSession is TRUE , destroy whole
user session namespace with authenticated bool and with userName string record.
Parameters
|
public static
string
|
#
EncodePasswordToHash( string $password = '', array $options = [] )
Get password hash by password_hash() with salt
by \MvcCore\Ext\Auths\Basic extension configuration or
by custom salt in second argument $options['salt'] = 'abcdefg'; .
Get password hash by password_hash() with salt
by \MvcCore\Ext\Auths\Basic extension configuration or
by custom salt in second argument $options['salt'] = 'abcdefg'; .
Parameters
- $password
- $options
- An options for
password_hash() .
Returns
string
See
http://php.net/manual/en/function.password-hash.php
|
public static
MvcCore\Session
|
#
GetSessionIdentity( )
MvcCore session namespace instance
to get/clear username record from session
to load user for authentication.
Session is automatically started if necessary
by \MvcCore\Session::GetNamespace(); .
MvcCore session namespace instance
to get/clear username record from session
to load user for authentication.
Session is automatically started if necessary
by \MvcCore\Session::GetNamespace(); .
Returns
|
public static
MvcCore\Session
|
|
public static
MvcCore\Session
|
#
GetSessionAuthorization( )
MvcCore session namespace instance
to get/clear username record from session
to load user for authentication.
Session is automatically started if necessary
by \MvcCore\Session::GetNamespace(); .
MvcCore session namespace instance
to get/clear username record from session
to load user for authentication.
Session is automatically started if necessary
by \MvcCore\Session::GetNamespace(); .
Returns
|
public static
MvcCore\Session
|
|
public
boolean
|
#
IsAdmin( )
Get if user is Administrator. Administrator has always allowed everything.
Get if user is Administrator. Administrator has always allowed everything.
Returns
boolean
|
public
boolean
|
#
GetAdmin( )
Get if user is Administrator. Administrator has always allowed everything.
Get if user is Administrator. Administrator has always allowed everything.
Returns
boolean
|
public
MvcCore\Ext\Auths\Basics\User
|
#
SetAdmin( boolean $admin = TRUE )
Set user to Administrator. Administrator has always allowed everything.
Set user to Administrator. Administrator has always allowed everything.
Parameters
Returns
|
public
string[]
&
|
#
GetRoles( )
Return array of user's roles names.
Return array of user's roles names.
Returns
string[]
|
public
MvcCore\Ext\Auths\Basics\User
|
|
public
MvcCore\Ext\Auths\Basics\User
|
|
public
boolean
|
#
HasRole( string|MvcCore\Ext\Auths\Basics\Role $roleOrRoleName )
Get TRUE if user has already assigned role or role name.
Get TRUE if user has already assigned role or role name.
Parameters
Returns
boolean
Throws
InvalidArgumentException
|
public
MvcCore\Ext\Auths\Basics\User
|
#
RemoveRole( string|MvcCore\Ext\Auths\Basics\Role $roleOrRoleName )
Remove user role or role name from user roles.
Remove user role or role name from user roles.
Parameters
Returns
Throws
InvalidArgumentException
|
public
boolean
|
#
IsAllowed( string|string[] $permissionNameOrNames, boolean $allPermissionsRequired = TRUE )
Get TRUE if given permission string(s) is/are (all or some) allowed for user or user role.
FALSE otherwise. Permission name could contain asterisk char * in any place.
Get TRUE if given permission string(s) is/are (all or some) allowed for user or user role.
FALSE otherwise. Permission name could contain asterisk char * in any place.
Parameters
- $permissionNameOrNames
- $allPermissionsRequired
TRUE by default.
Returns
boolean
|
public
boolean
|
#
GetPermission( string $permissionName )
Get TRUE if given permission string is allowed for user or role. FALSE otherwise.
Get TRUE if given permission string is allowed for user or role. FALSE otherwise.
Parameters
Returns
boolean
|
public
MvcCore\Ext\Auths\Basics\User
|
#
SetPermission( string $permissionName, boolean $allow = TRUE )
Set $permissionName string with $allow boolean to allow
or to disallow permission (with $allow = FALSE ) for user or role.
Set $permissionName string with $allow boolean to allow
or to disallow permission (with $allow = FALSE ) for user or role.
Parameters
- $permissionName
- Strings describing what is allowed/disallowed to do for user or role.
- $allow
TRUE by default.
Returns
|
public
string[]
&
|
#
GetPermissions( )
Get array of strings describing what is allowed to do for user or role.
Get array of strings describing what is allowed to do for user or role.
Returns
string[]
|
public
MvcCore\Ext\Auths\Basics\User
|
#
SetPermissions( string|string[] $permissions )
Set array of strings describing what is allowed to do for user or role.
Set array of strings describing what is allowed to do for user or role.
Parameters
- $permissions
- The permissions string, separated by comma character or array of strings.
Returns
|
public static
MvcCore\Ext\Auths\Basics\User
|
#
GetByUserName( string $userName )
Get user model instance from database or any other users list
resource by submitted and cleaned $userName field value.
Get user model instance from database or any other users list
resource by submitted and cleaned $userName field value.
Parameters
- $userName
- Submitted and cleaned username. Characters
' " < > \ = ^ | & ~are automatically encoded to html entities by default \MvcCore\Ext\Auths\Basic` sign in form.
Returns
|