SelfHelp WebApp  v2.0.6
A WebApp to Create WebApps for Studies in Human Sciences
Login Class Reference

Public Member Functions

 __construct ($db, $store_url=false, $redirect=false)
 
 check_credentials ($email, $password)
 
 change_password ($password)
 
 create_token ()
 
 delete_user ($uid, $email)
 
 get_target_url ($default_url)
 
 is_logged_in ()
 
 logout ()
 

Private Member Functions

 init_session ()
 
 update_last_url ($id, $url)
 
 update_timestamp ($id)
 

Private Attributes

 $db
 
 $store_url
 
 $redirect
 

Detailed Description

This class allows to check wheter a login is valid.

Constructor & Destructor Documentation

◆ __construct()

Login::__construct (   $db,
  $store_url = false,
  $redirect = false 
)

Start the session.

Parameters
object$dbThe db instance which grants access to the DB.
bool$store_urlIf true the current url is stored as last url in the db.
bool$redirectIf true the user is redirected to the current url after login.
Here is the call graph for this function:

Member Function Documentation

◆ change_password()

Login::change_password (   $password)

Change the password of the active user.

Parameters
string$passwordThe new password.
Return values
boolTrue if the change was successful, false otherwise

◆ check_credentials()

Login::check_credentials (   $email,
  $password 
)

Check login credentials with the db and set the session variable if successful. If the check fails, the session variable is destroyed.

Parameters
string$emailThe email address of the user.
string$passwordThe password string entered by the user.
Return values
booltrue if the check was successful, false otherwise.
Here is the call graph for this function:

◆ create_token()

Login::create_token ( )

Create a random token string that can be used for verification.

Return values
stringA random string.

◆ delete_user()

Login::delete_user (   $uid,
  $email 
)

Delete the user if the given email address matches with the email address stored in the database.

Parameters
int$uidThe user id.
string$emailThe user email address.
Return values
boolTrue if the deleting process was successful, false otherwise.

◆ get_target_url()

Login::get_target_url (   $default_url)

Get the target URL to redirec after login. This is either

  1. a target url specified by a link
  2. the last used url by the user
  3. the home url
Return values
stringThe target URL.
Here is the call graph for this function:

◆ init_session()

Login::init_session ( )
private

Initialise the php session.

Referenced by __construct(), and logout().

Here is the call graph for this function:

◆ is_logged_in()

Login::is_logged_in ( )

Check whether the user is logged in by ckecking for a user id in the session variable.

Return values
booltrue if the user is logged in, false otherwise.

Referenced by get_target_url(), and init_session().

◆ logout()

Login::logout ( )

Logout the user by removing all session variables and destroying the session.

Here is the call graph for this function:

◆ update_last_url()

Login::update_last_url (   $id,
  $url 
)
private

Update the last visited url of the active user.

Parameters
$idThe user id
$urlThe target url

Referenced by init_session().

◆ update_timestamp()

Login::update_timestamp (   $id)
private

Update the timestamp of the last login.

Parameters
int$idThe user id
Return values
intThe number of affected rows or false on failure.

Referenced by check_credentials().

Member Data Documentation

◆ $db

Login::$db
private

The db instance which grants access to the DB.

Referenced by __construct().

◆ $redirect

Login::$redirect
private

If true the user is redirected to the current url after login.

Referenced by __construct().

◆ $store_url

Login::$store_url
private

If true the current url is stored as last url in the db.

Referenced by __construct().


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