mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 16:32:20 +00:00
Shit
This commit is contained in:
@@ -59,7 +59,7 @@ $autoload['packages'] = array();
|
||||
| $autoload['libraries'] = array('user_agent' => 'ua');
|
||||
*/
|
||||
//$autoload['libraries'] = array();
|
||||
$autoload['libraries'] = array('session');
|
||||
$autoload['libraries'] = array('session', 'FHC_Auth');
|
||||
|
||||
/*
|
||||
| -------------------------------------------------------------------
|
||||
|
||||
@@ -508,7 +508,7 @@ $config['proxy_ips'] = '';
|
||||
| Autoload Custom Controllers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
*/
|
||||
Don't work so sometime delete this*/
|
||||
function __autoload($class)
|
||||
{
|
||||
if (substr($class,0,3) !== 'CI_' && substr($class,0,4) !== 'FHC_')
|
||||
|
||||
@@ -110,7 +110,7 @@ $config['rest_realm'] = 'FHC REST API';
|
||||
| authorization key
|
||||
|
|
||||
*/
|
||||
$config['rest_auth'] = ' basic';
|
||||
$config['rest_auth'] = 'basic';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
@@ -29,7 +29,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*
|
||||
* A more detailed class description.
|
||||
*/
|
||||
class Rest_server extends MY_Controller {
|
||||
class Rest_server extends FHC_Controller {
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
@@ -17,12 +17,13 @@
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
// This can be removed if you use __autoload() in config.php OR use Modular Extensions
|
||||
require APPPATH . '/libraries/REST_Controller.php';
|
||||
//require APPPATH . '/libraries/REST_Controller.php';
|
||||
|
||||
/**
|
||||
* Handles user authentication and registration process
|
||||
*/
|
||||
class AuthAPI extends REST_Controller {
|
||||
class AuthAPI extends APIv1_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Userauth-Controller constructor.
|
||||
@@ -39,8 +40,9 @@ class AuthAPI extends REST_Controller {
|
||||
$this->methods['login_get']['limit'] = 500; // 500 requests per hour per user/key
|
||||
|
||||
// Load helper
|
||||
$this->load->helper('fhcauth');
|
||||
//$this->load->helper('fhcauth');
|
||||
$this->load->library('session');
|
||||
$this->load->library('FHC_Auth');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,7 +60,7 @@ class AuthAPI extends REST_Controller {
|
||||
$username = urldecode($this->get('username'));
|
||||
$password = urldecode($this->get('password'));
|
||||
|
||||
$account = auth($username,$password);
|
||||
$account = $this->FHCAuth->auth($username,$password);
|
||||
|
||||
// perform login checks
|
||||
if (!$account)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
defined('BASEPATH') || exit('No direct script access allowed');
|
||||
|
||||
class Person extends REST_Controller
|
||||
class Person extends APIv1_Controller
|
||||
{
|
||||
//public $session;
|
||||
/**
|
||||
@@ -42,11 +42,11 @@ class Person extends REST_Controller
|
||||
$result = $this->person_model->getPerson();
|
||||
// var_dump($result[0]);
|
||||
|
||||
if (empty($result))
|
||||
if ($result['err'])
|
||||
{
|
||||
$payload = [
|
||||
'success' => false,
|
||||
'message' => 'Person not found'
|
||||
'message' => $result['msg'].': '.$result['retval']
|
||||
];
|
||||
$httpstatus = REST_Controller::HTTP_OK;
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
// This can be removed if you use __autoload() in config.php OR use Modular Extensions
|
||||
//require APPPATH . '/libraries/REST_Controller.php';
|
||||
|
||||
class API_Controller extends REST_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
//$this->load->library('session'); -> autoload
|
||||
//$this->load->library('database'); -> autoload
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,7 +12,7 @@ class FHC_Controller extends CI_Controller
|
||||
|
||||
require_once APPPATH . '/libraries/REST_Controller.php';
|
||||
|
||||
class API_Controller extends REST_Controller
|
||||
class APIv1_Controller extends REST_Controller
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class FHC_Model extends CI_Model
|
||||
{
|
||||
//protected errormsg;
|
||||
function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
@@ -31,12 +32,13 @@ class FHC_Model extends CI_Model
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function _general_error()
|
||||
protected function _general_error($retval = '', $message = FHC_ERR_GENERAL)
|
||||
{
|
||||
return array(
|
||||
'err' => 1,
|
||||
'code' => FHC_ERR_GENERAL,
|
||||
'msg' => lang('fhc_'.FHC_ERR_GENERAL)
|
||||
'msg' => lang('fhc_'.$message),
|
||||
'retval' => $retval
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* @filesource
|
||||
*/
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
require_once 'include/authentication.class.php';
|
||||
require_once FCPATH.'include/authentication.class.php';
|
||||
|
||||
/**
|
||||
* FHC-Auth Helpers
|
||||
@@ -39,12 +39,12 @@ class FHC_Auth
|
||||
$auth = new authentication();
|
||||
if ($auth->checkpassword($username, $password))
|
||||
{
|
||||
echo 'Auth-Method-True';
|
||||
//echo 'Auth-Method-True';
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo 'Auth-Method-False';
|
||||
//echo 'Auth-Method-False';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -434,7 +434,7 @@ abstract class REST_Controller extends CI_Controller {
|
||||
$language = $this->config->item('rest_language');
|
||||
if ($language === NULL)
|
||||
{
|
||||
$language = 'english';
|
||||
$language = 'en-US';
|
||||
}
|
||||
|
||||
// Load the language file
|
||||
|
||||
@@ -19,6 +19,11 @@ class Person_model extends DB_Model
|
||||
return $query->row_object();
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt Personendaten einer Person mittels Code
|
||||
* @param string $code DB-Attr: tbl_benutzer.zugangscode .
|
||||
* @return object
|
||||
*/
|
||||
public function getPersonByCode($code)
|
||||
{
|
||||
if ($this->fhc_db_acl->bb->isBerechtigt('person','s'))
|
||||
@@ -26,6 +31,11 @@ class Person_model extends DB_Model
|
||||
$query = $this->db->get_where('public.tbl_person', array('zugangscode' => $code));
|
||||
return $query->result_object();
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->_general_error($this->fhc_db_acl->bb->errormsg);
|
||||
//return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+24
-3
@@ -289,8 +289,29 @@ switch (ENVIRONMENT)
|
||||
* And away we go...
|
||||
*/
|
||||
//require_once BASEPATH.'core/CodeIgniter.php';
|
||||
//require_once(dirname(__FILE__).'/include/authentication.class.php');
|
||||
require_once(dirname(__FILE__).'/vendor/codeigniter/framework/system/core/Common.php');
|
||||
require_once(dirname(__FILE__).'/vendor/codeigniter/framework/system/core/Controller.php');
|
||||
/*
|
||||
* ------------------------------------------------------
|
||||
* Instantiate the config class
|
||||
* ------------------------------------------------------
|
||||
*
|
||||
* Note: It is important that Config is loaded first as
|
||||
* most other classes depend on it either directly or by
|
||||
* depending on another class that uses it.
|
||||
*
|
||||
*/
|
||||
$CFG =& load_class('Config', 'core');
|
||||
|
||||
// FH-Complete Hacks for uebergangszeit
|
||||
// Do we have any manually set config items in the index.php file?
|
||||
if (isset($assign_to_config) && is_array($assign_to_config))
|
||||
{
|
||||
foreach ($assign_to_config as $key => $value)
|
||||
{
|
||||
$CFG->set_item($key, $value);
|
||||
}
|
||||
}
|
||||
function &get_instance()
|
||||
{
|
||||
return CI_Controller::get_instance();
|
||||
@@ -301,10 +322,10 @@ require_once(dirname(__FILE__).'/vendor/codeigniter/framework/system/database/DB
|
||||
require_once(dirname(__FILE__).'/vendor/codeigniter/framework/system/core/Common.php');
|
||||
require_once(dirname(__FILE__).'/vendor/codeigniter/framework/system/core/Loader.php');
|
||||
$loader=new CI_Loader();
|
||||
require_once(dirname(__FILE__).'/vendor/codeigniter/framework/system/core/Controller.php');
|
||||
//require_once(dirname(__FILE__).'/application/core/FHC_Controller.php');
|
||||
$controller=new CI_Controller();
|
||||
require_once(dirname(__FILE__).'/vendor/codeigniter/framework/system/core/Model.php');
|
||||
require_once(dirname(__FILE__).'/application/core/MY_Model.php');
|
||||
require_once(dirname(__FILE__).'/application/core/FHC_Model.php');
|
||||
$model=new CI_Model();
|
||||
|
||||
// Traits
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
$I = new ApiTester($scenario);
|
||||
$I->wantTo('test the Login API');
|
||||
$I->haveHttpHeader('FHC-API-KEY', 'testapikey@fhcomplete.org');
|
||||
$I->sendGET('/userauth/login/username/codeception%40whisperocity.com/password/secret/device_id/abcdef123');
|
||||
$I->sendGET('AuthAPI/login?username=pam&password=1q2w3&FHC-API-KEY=testapikey@fhcomplete.org');
|
||||
$I->seeResponseCodeIs(200);
|
||||
$I->seeResponseIsJson();
|
||||
$I->seeResponseContainsJson([
|
||||
|
||||
Reference in New Issue
Block a user