Trait Auth
Trait for \MvcCore\Ext\Auths\Basics\User
class. Trait contains:
- Static property $sessionIdentity
with their public setter and getter with expiration settings.
- Static property $sessionAuthorization
with their public setter and getter with expiration settings.
- Static methods LogIn()
and LogOut()
to authenticate or remove user from session namespace.
- Static method EncodePasswordToHash()
to hash password with custom or configured salt and other options.
Methods summary
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 agument $options['salt'] = 'abcdefg'; .
Get password hash by password_hash() with salt
by \MvcCore\Ext\Auths\Basic extension configuration or
by custom salt in second agument $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
|
|
protected static
boolean
|
#
hashEquals( string $hash1, string $hash2 )
Backward compatible hash equals for PHP 5.4.
Backward compatible hash equals for PHP 5.4.
Parameters
Returns
boolean
|
Properties summary
protected static
MvcCore\Session
|
$sessionIdentity
MvcCore session namespace instance
to get/clear username record from session
to load user for authentication.
MvcCore session namespace instance
to get/clear username record from session
to load user for authentication.
|
|
protected static
MvcCore\Session
|
$sessionAuthorization
MvcCore session namespace instance
to get/set authentication boolean record
about authenticated/not authenticated user.
MvcCore session namespace instance
to get/set authentication boolean record
about authenticated/not authenticated user.
|
|
private static
string
|
$_sessionClass
MvcCore cached session class string.
MvcCore cached session class string.
|
|