Class \Scrivo\LoginKey
Add a login_events record with a temporary key that can be used to log in.
The following fields should be populated:
instance_id Instance id
date_login Time of the login event (for timeout)
user_id User id
return_code 0: OK, 1: invalid pwd, 2: invalid ucode
remote_address Client IP-address
access_key Random key
Login return codes: 0: valid login credentials 0: login failed, invalid key
An alternative function can defined in the .htscrivo file (LOGIN_PROVIDER refers to a php script that implements the function 'login_key()'. This is usefull if you want to use another user database to log in (LDAP). You still need to match roles on both systems, but you can write a function that does the authentication on the external system and if authenticated simply insert a row in the login_events table. Note that you still need a user in the Scrivo database, but that is only functional: a user id is used to retreive the roles. Simply insert a new user on login and link it with the corresponding roles.
Defined in: LoginKey.php.
Attr. | Name / Description |
---|---|
public |
LoginKey($context) Create a login object to either generate or verify a login key. |
Name | Description |
---|---|
INVALID_IP | Value to indicate that login was unsuccesfull because login key generation and verification action were initiated using a different ip addresses. |
INVALID_PASSWORD | Value to indicate that login was unsuccesfull due to an invalid password. |
INVALID_USERCODE | Value to indicate that login was unsuccesfull due to an invalid usercode. |
LOGIN_SUCCESSFULL | Value to indicate that login was succesfull. |
TIMEOUT | Value to indicate that login was unsuccesfull because of a time out when verifying the key. |
Attr. | Type | Name | Description |
---|---|---|---|
protected | \..\Context | $context | A Scrivo context. |
Attr. | Type | Name / Description |
---|---|---|
public | \..\String |
generate($usercode, $password) Generate a login key for a given usercode and password. |
public |
insert($userId, $loginStatus, $key) Insert an entry in the login_events table, this entry will be checked by LoginKey::verify(). |
|
public | \..\User |
verify($key) Verify the login key, return the user if succesfull, NULL if not. |
Constructor
- public LoginKey(\Scrivo\Context $context)
-
Create a login object to either generate or verify a login key.
Parameters:
Type Name Def. Description \Scrivo\Context $context A valid Scrivo context.
View source: LoginKey.php line 107.
Constants
- INVALID_IP
-
Value to indicate that login was unsuccesfull because login key generation and verification action were initiated using a different ip addresses.
Value: 4
View source: LoginKey.php line 88.
- INVALID_PASSWORD
-
Value to indicate that login was unsuccesfull due to an invalid password.
Value: 1
View source: LoginKey.php line 71.
- INVALID_USERCODE
-
Value to indicate that login was unsuccesfull due to an invalid usercode.
Value: 2
View source: LoginKey.php line 76.
- LOGIN_SUCCESSFULL
-
Value to indicate that login was succesfull.
Value: 3
View source: LoginKey.php line 81.
- TIMEOUT
-
Value to indicate that login was unsuccesfull because of a time out when verifying the key.
Value: 5
View source: LoginKey.php line 94.
Members
- protected \Scrivo\Context $context
-
A Scrivo context.
Inital value: null
View source: LoginKey.php line 100.
Methods
- public \Scrivo\String generate(\Scrivo\String $usercode, \Scrivo\String $password)
-
Generate a login key for a given usercode and password.
Override this function if you want to verify the user against another autentication database.
Parameters:
Type Name Def. Description \Scrivo\String $usercode A user code.
\Scrivo\String $password A password.
Returns:
\Scrivo\String Generate a login key for a given usercode and password.
View source: LoginKey.php line 121.
- public insert(int $userId, int $loginStatus, \Scrivo\String $key)
-
Insert an entry in the login_events table, this entry will be checked by LoginKey::verify().
Parameters:
Type Name Def. Description int $userId A user id if password verification was succesfull, -1 if not.
int $loginStatus The result of the password verification: either \Scrivo\LoginKey::INVALID_USERCODE, \Scrivo\LoginKey::INVALID_PASSWORD or 0 (no error).
\Scrivo\String $key A generated random key.
View source: LoginKey.php line 168.
- public \Scrivo\User verify(\Scrivo\String $key)
-
Verify the login key, return the user if succesfull, NULL if not.
Also update the login_events table with the result of the verification.
Parameters:
Type Name Def. Description \Scrivo\String $key A key that was previously generated by LoginKey::generate()
Returns:
\Scrivo\User Verify the login key, return the user if succesfull, NULL if not.
View source: LoginKey.php line 198.
Documentation generated by phpDocumentor 2.0.0a12 and ScrivoDocumentor on August 29, 2013