mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-24 02:12:17 +00:00
- Moved all the code related to authentication to AuthLib
- Changed configuration files autoload.php and rest.php to use AuthLib - Added new method getCheckUserAuth to controller CheckUserAuth.php - Removed libraries/FHC_Auth.php - Removed models/CheckUserAuth_model.php - Removed include/AddonAuthentication.php
This commit is contained in:
@@ -22,18 +22,23 @@ class CheckUserAuth extends APIv1_Controller
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('CheckUserAuth_model', 'CheckUserAuthModel');
|
||||
|
||||
// Loads the authentication library
|
||||
$this->load->library('AuthLib');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if username and password of a final user are valid
|
||||
*/
|
||||
public function getCheckByUsernamePassword()
|
||||
{
|
||||
$username = $this->get("username");
|
||||
$password = $this->get("password");
|
||||
|
||||
$username = $this->get('username');
|
||||
$password = $this->get('password');
|
||||
|
||||
if (isset($username) && isset($password))
|
||||
{
|
||||
$result = $this->CheckUserAuthModel->checkByUsernamePassword($username, $password);
|
||||
|
||||
$result = $this->authlib->CheckUserAuthByUsernamePassword($username, $password);
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
else
|
||||
@@ -41,4 +46,45 @@ class CheckUserAuth extends APIv1_Controller
|
||||
$this->response();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if username and password of a final user are valid
|
||||
* Returns all the keys with which is possible to obtain all the personal data about a final user
|
||||
*/
|
||||
public function getCheckUserAuth()
|
||||
{
|
||||
$code = $this->get('code');
|
||||
$email = $this->get('email');
|
||||
$username = $this->get('username');
|
||||
$password = $this->get('password');
|
||||
|
||||
$result = null;
|
||||
$httpCode = null;
|
||||
|
||||
// If username and password are given then check authentication using them
|
||||
if (isset($username) && isset($password))
|
||||
{
|
||||
$result = $this->authlib->CheckUserAuthByUsernamePassword($username, $password, true);
|
||||
}
|
||||
elseif (isset($code) || isset($email))
|
||||
{
|
||||
// If code and email are given then check authentication using them
|
||||
if (isset($code) && isset($email))
|
||||
{
|
||||
$result = $this->authlib->CheckUserAuthByCodeEmail($code, $email);
|
||||
}
|
||||
else // otherwise check authentication using only code
|
||||
{
|
||||
$result = $this->authlib->CheckUserAuthByCode($code);
|
||||
}
|
||||
}
|
||||
|
||||
// If is a success and contains data
|
||||
if (hasData($result))
|
||||
{
|
||||
$httpCode = REST_Controller::HTTP_OK;
|
||||
}
|
||||
|
||||
$this->response($result, $httpCode);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user