- Added controller CheckUserAuth to authenticate the end user

- FHC_Auth now extends directly authentication
This commit is contained in:
paolo
2016-06-14 15:19:34 +02:00
parent f5ebe0c42b
commit a8b7be6ad5
3 changed files with 75 additions and 3 deletions
@@ -0,0 +1,44 @@
<?php
/**
* FH-Complete
*
* @package FHC-API
* @author FHC-Team
* @copyright Copyright (c) 2016, fhcomplete.org
* @license GPLv3
* @link http://fhcomplete.org
* @since Version 1.0
* @filesource
*/
// ------------------------------------------------------------------------
if (!defined('BASEPATH')) exit('No direct script access allowed');
class CheckUserAuth extends APIv1_Controller
{
/**
* Course API constructor.
*/
public function __construct()
{
parent::__construct();
$this->load->model('CheckUserAuth_model', 'CheckUserAuthModel');
}
public function getCheckByUsernamePassword()
{
$username = $this->get("username");
$password = $this->get("password");
if (isset($username) && isset($password))
{
$result = $this->CheckUserAuthModel->checkByUsernamePassword($username, $password);
$this->response($result, REST_Controller::HTTP_OK);
}
else
{
$this->response();
}
}
}
+13 -3
View File
@@ -26,8 +26,16 @@ require_once FCPATH.'include/AddonAuthentication.php';
// ------------------------------------------------------------------------
class FHC_Auth
class FHC_Auth extends authentication
{
/**
* Construct
*/
public function __construct()
{
parent::__construct();
}
/**
* Auth Username, Password over FH-Complete
*
@@ -37,8 +45,7 @@ class FHC_Auth
*/
public function basicAuthentication($username, $password)
{
$auth = new authentication();
if ($auth->checkpassword($username, $password))
if ($this->checkpassword($username, $password))
{
return true;
}
@@ -49,6 +56,9 @@ class FHC_Auth
}
/**
*
* TO BE UPDATED
*
* Get the md5 hashed password by the addon username
*
* @param string $username addon username
@@ -0,0 +1,18 @@
<?php
class CheckUserAuth_model extends FHC_Model
{
/**
* Construct
*/
public function __construct()
{
parent::__construct();
$this->load->library('fhc_auth');
}
public function checkByUsernamePassword($username, $password)
{
return $this->_success($this->fhc_auth->checkpassword($username, $password));
}
}