mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-22 06:29:27 +00:00
- Added controller CheckUserAuth to authenticate the end user
- FHC_Auth now extends directly authentication
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user