myfir-login
This commit is contained in:
@@ -47,10 +47,16 @@ $routes->get('/en/desktop/api/v2/myfit/faq', 'Myfit::faq');
|
|||||||
$routes->post('/en/desktop/api/v2/myfit/contact', 'Myfit::contact');
|
$routes->post('/en/desktop/api/v2/myfit/contact', 'Myfit::contact');
|
||||||
$routes->get('/en/desktop/api/v2/myfit/pricing', 'Myfit::pricing');
|
$routes->get('/en/desktop/api/v2/myfit/pricing', 'Myfit::pricing');
|
||||||
|
|
||||||
//MYFIT USERS
|
//MYFIT DESKTOP USERS
|
||||||
$routes->post('/en/desktop/api/v2/myfituser/login', 'Myfituser::users');
|
$routes->post('/en/desktop/api/v2/myfituser/login', 'Myfituser::users');
|
||||||
$routes->post('/en/desktop/api/v2/myfituser/account', 'Myfituser::users');
|
$routes->post('/en/desktop/api/v2/myfituser/account', 'Myfituser::users');
|
||||||
|
|
||||||
|
//MYFIT DESKTOP USERS
|
||||||
|
$routes->post('/en/mobile/api/v2/myfituser/login', 'Myfituser::users');
|
||||||
|
$routes->post('/en/mobile/api/v2/myfituser/account', 'Myfituser::users');
|
||||||
|
$routes->get('/en/mobile/api/v2/myfit/blogdata', 'Myfit::blogdata');
|
||||||
|
|
||||||
|
|
||||||
$routes->get('/en/desktop/api/v2/myfituser/profile', 'Myfituser::users');
|
$routes->get('/en/desktop/api/v2/myfituser/profile', 'Myfituser::users');
|
||||||
$routes->get('/en/desktop/api/v2/myfituser/myfeed', 'Myfituser::users');
|
$routes->get('/en/desktop/api/v2/myfituser/myfeed', 'Myfituser::users');
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use CodeIgniter\HTTP\RequestInterface;
|
use CodeIgniter\HTTP\RequestInterface;
|
||||||
@@ -16,15 +15,14 @@ class Myfituser extends BaseController
|
|||||||
$this->request = $request = \Config\Services::request();
|
$this->request = $request = \Config\Services::request();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
header("Access-Control-Allow-Origin: * ");
|
header('Access-Control-Allow-Origin: * ');
|
||||||
//header("Access-Control-Allow-Origin: http://localhost:9057 ");
|
//header("Access-Control-Allow-Origin: http://localhost:9057 ");
|
||||||
header("Access-Control-Expose-Headers: Access-Control-Allow-Origin");
|
header('Access-Control-Expose-Headers: Access-Control-Allow-Origin');
|
||||||
header("Access-Control-Allow-Credentials: true ");
|
header('Access-Control-Allow-Credentials: true ');
|
||||||
//header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With");
|
//header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With");
|
||||||
header("Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS");
|
header('Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS');
|
||||||
header('Content-type: application/json');
|
header('Content-type: application/json');
|
||||||
|
|
||||||
$mBlogData = new \App\Models\myfitBlogData();
|
$mBlogData = new \App\Models\myfitBlogData();
|
||||||
@@ -34,63 +32,47 @@ class Myfituser extends BaseController
|
|||||||
|
|
||||||
public function users()
|
public function users()
|
||||||
{
|
{
|
||||||
header("Access-Control-Allow-Origin: * ");
|
header('Access-Control-Allow-Origin: * ');
|
||||||
//header("Access-Control-Allow-Origin: http://localhost:9057 ");
|
//header("Access-Control-Allow-Origin: http://localhost:9057 ");
|
||||||
header("Access-Control-Expose-Headers: Access-Control-Allow-Origin");
|
header('Access-Control-Expose-Headers: Access-Control-Allow-Origin');
|
||||||
header("Access-Control-Allow-Credentials: true ");
|
header('Access-Control-Allow-Credentials: true ');
|
||||||
//header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With");
|
//header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With");
|
||||||
header("Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS");
|
header('Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS');
|
||||||
header('Content-type: application/json');
|
header('Content-type: application/json');
|
||||||
|
|
||||||
|
// what is the endpoint
|
||||||
|
$uri = current_url(true);
|
||||||
|
$pieces = explode('/', $uri);
|
||||||
|
$psc = count($pieces);
|
||||||
|
|
||||||
// what is the endpoint
|
$endpoint = $psc > 0 ? $pieces[$psc - 1] : '';
|
||||||
$uri = current_url(true);
|
|
||||||
$pieces = explode("/", $uri);
|
|
||||||
$psc = count($pieces);
|
|
||||||
|
|
||||||
$endpoint = ( $psc > 0) ? $pieces[ $psc-1] : '';
|
$endpoints = [
|
||||||
|
'createuser' => ['POST'],
|
||||||
$endpoints = array(
|
'login' => ['POST'],
|
||||||
'createuser' => array('POST'),
|
|
||||||
'userlogin' => array('POST'),
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
if(array_key_exists( $endpoint, $endpoints)){
|
|
||||||
// echo "EXYTACT INPUT DATA HERE";
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
http_response_code(404);
|
|
||||||
// tell the user product does not exist
|
|
||||||
echo json_encode(array("message" => "Product does not exist."));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$raw_json = file_get_contents("php://input");
|
|
||||||
$raw_array = json_decode($raw_json, true);
|
|
||||||
// $something = $raw_array["name"];
|
|
||||||
|
|
||||||
$sqlQ = "SELECT m.*,mp.* FROM members m LEFT JOIN members_profile mp ON m.id=mp.member_id WHERE m.id =12";
|
|
||||||
$db = \Config\Database::connect('mermsemr');
|
|
||||||
$query = $db->query( $sqlQ );
|
|
||||||
$data['test_data'] = $query->getResultArray();
|
|
||||||
|
|
||||||
|
|
||||||
$inx = [
|
|
||||||
'message_id' => rand(100, 8888) . 'gsgsgsgsg-sssfsgggsgs-ususususu',
|
|
||||||
'test'=> $sqlQ,
|
|
||||||
'test_data' => $data['test_data'],
|
|
||||||
'status'=>1,
|
|
||||||
'endpoint'=>$endpoint,
|
|
||||||
'raw_data'=> $raw_array
|
|
||||||
];
|
];
|
||||||
return $this->response->setJson($inx);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// $raw_array = [];
|
||||||
|
if (array_key_exists($endpoint, $endpoints)) {
|
||||||
|
} else {
|
||||||
|
http_response_code(404);
|
||||||
|
// tell the user product does not exist
|
||||||
|
echo json_encode(['message' => 'Enpoint not found.']);
|
||||||
|
}
|
||||||
|
// echo "EXYTACT INPUT DATA HERE";
|
||||||
|
$raw_json = file_get_contents('php://input');
|
||||||
|
$raw_array = json_decode($raw_json, true);
|
||||||
|
|
||||||
|
|
||||||
|
$userAccess = new \App\Models\userAccess();
|
||||||
|
$res1 = $userAccess->startLogin($raw_array);
|
||||||
|
|
||||||
|
return $this->response->setJson($res1);
|
||||||
|
}
|
||||||
|
|
||||||
public function blogdata()
|
public function blogdata()
|
||||||
{
|
{
|
||||||
/* header("Access-Control-Allow-Origin: *");
|
/* header("Access-Control-Allow-Origin: *");
|
||||||
//header("x-devicetoken : *");
|
//header("x-devicetoken : *");
|
||||||
//header("Authorization : Token");
|
//header("Authorization : Token");
|
||||||
header("Access-Control-Expose-Headers: Access-Control-Allow-Origin");
|
header("Access-Control-Expose-Headers: Access-Control-Allow-Origin");
|
||||||
@@ -103,28 +85,28 @@ class Myfituser extends BaseController
|
|||||||
header2 = ('Access-Control-Allow-Origin', 'https://serviceview.example.com')
|
header2 = ('Access-Control-Allow-Origin', 'https://serviceview.example.com')
|
||||||
|
|
||||||
*/
|
*/
|
||||||
header("Access-Control-Allow-Origin: * ");
|
header('Access-Control-Allow-Origin: * ');
|
||||||
//header("Access-Control-Allow-Origin: http://localhost:9057 ");
|
//header("Access-Control-Allow-Origin: http://localhost:9057 ");
|
||||||
header("Access-Control-Expose-Headers: Access-Control-Allow-Origin");
|
header('Access-Control-Expose-Headers: Access-Control-Allow-Origin');
|
||||||
header("Access-Control-Allow-Credentials: true ");
|
header('Access-Control-Allow-Credentials: true ');
|
||||||
//header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With");
|
//header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With");
|
||||||
header("Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS");
|
header('Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS');
|
||||||
header('Content-type: application/json');
|
header('Content-type: application/json');
|
||||||
|
|
||||||
$mBlogData = new \App\Models\myfitBlogData();
|
$mBlogData = new \App\Models\myfitBlogData();
|
||||||
$res1 = $mBlogData->getBlogData([]);
|
$res1 = $mBlogData->getBlogData([]);
|
||||||
return $this->response->setJson($res1);
|
return $this->response->setJson($res1);
|
||||||
// $this->setGetReturn(res1);
|
// $this->setGetReturn(res1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function country()
|
public function country()
|
||||||
{
|
{
|
||||||
//header("Access-Control-Allow-Origin: http://localhost:9057 ");
|
//header("Access-Control-Allow-Origin: http://localhost:9057 ");
|
||||||
header("Access-Control-Allow-Origin: * ");
|
header('Access-Control-Allow-Origin: * ');
|
||||||
header("Access-Control-Expose-Headers: Access-Control-Allow-Origin");
|
header('Access-Control-Expose-Headers: Access-Control-Allow-Origin');
|
||||||
header("Access-Control-Allow-Credentials: true ");
|
header('Access-Control-Allow-Credentials: true ');
|
||||||
//header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With");
|
//header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With");
|
||||||
header("Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS");
|
header('Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS');
|
||||||
header('Content-type: application/json');
|
header('Content-type: application/json');
|
||||||
|
|
||||||
$mCountry = new \App\Models\myfitCountry();
|
$mCountry = new \App\Models\myfitCountry();
|
||||||
@@ -134,11 +116,11 @@ class Myfituser extends BaseController
|
|||||||
public function faq()
|
public function faq()
|
||||||
{
|
{
|
||||||
//header("Access-Control-Allow-Origin: http://localhost:9057 ");
|
//header("Access-Control-Allow-Origin: http://localhost:9057 ");
|
||||||
header("Access-Control-Allow-Origin: * ");
|
header('Access-Control-Allow-Origin: * ');
|
||||||
header("Access-Control-Expose-Headers: Access-Control-Allow-Origin");
|
header('Access-Control-Expose-Headers: Access-Control-Allow-Origin');
|
||||||
header("Access-Control-Allow-Credentials: true ");
|
header('Access-Control-Allow-Credentials: true ');
|
||||||
//header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With");
|
//header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With");
|
||||||
header("Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS");
|
header('Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS');
|
||||||
header('Content-type: application/json');
|
header('Content-type: application/json');
|
||||||
|
|
||||||
$mFaq = new \App\Models\myfitFaqData();
|
$mFaq = new \App\Models\myfitFaqData();
|
||||||
@@ -148,24 +130,25 @@ class Myfituser extends BaseController
|
|||||||
public function pricing()
|
public function pricing()
|
||||||
{
|
{
|
||||||
//header("Access-Control-Allow-Origin: http://localhost:9057 ");
|
//header("Access-Control-Allow-Origin: http://localhost:9057 ");
|
||||||
header("Access-Control-Allow-Origin: * ");
|
header('Access-Control-Allow-Origin: * ');
|
||||||
header("Access-Control-Expose-Headers: Access-Control-Allow-Origin");
|
header('Access-Control-Expose-Headers: Access-Control-Allow-Origin');
|
||||||
header("Access-Control-Allow-Credentials: true ");
|
header('Access-Control-Allow-Credentials: true ');
|
||||||
//header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With");
|
//header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With");
|
||||||
header("Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS");
|
header('Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS');
|
||||||
header('Content-type: application/json');
|
header('Content-type: application/json');
|
||||||
|
|
||||||
$mPricing = new \App\Models\myfitPricing();
|
$mPricing = new \App\Models\myfitPricing();
|
||||||
return $this->response->setJson($mPricing->getSitePricing([]));
|
return $this->response->setJson($mPricing->getSitePricing([]));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setGetReturn($resp){
|
private function setGetReturn($resp)
|
||||||
header("Access-Control-Allow-Origin: * ");
|
{
|
||||||
|
header('Access-Control-Allow-Origin: * ');
|
||||||
//header("Access-Control-Allow-Origin: http://localhost:9057 ");
|
//header("Access-Control-Allow-Origin: http://localhost:9057 ");
|
||||||
header("Access-Control-Expose-Headers: Access-Control-Allow-Origin");
|
header('Access-Control-Expose-Headers: Access-Control-Allow-Origin');
|
||||||
header("Access-Control-Allow-Credentials: true ");
|
header('Access-Control-Allow-Credentials: true ');
|
||||||
//header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With");
|
//header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With");
|
||||||
header("Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS");
|
header('Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS');
|
||||||
header('Content-type: application/json');
|
header('Content-type: application/json');
|
||||||
return $this->response->setJson($resp);
|
return $this->response->setJson($resp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
<?php
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use CodeIgniter\Model;
|
||||||
|
|
||||||
|
class userAccess extends Model
|
||||||
|
{
|
||||||
|
protected $db;
|
||||||
|
public $con_name = 'mermsemr';
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
//$db = \Config\Database::connect('mermsemr');
|
||||||
|
$this->db = \Config\Database::connect($this->con_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function startLogin($in)
|
||||||
|
{
|
||||||
|
$sqlQ =
|
||||||
|
'SELECT m.*,mp.* FROM members m LEFT JOIN members_profile mp ON m.id=mp.member_id WHERE m.id =12';
|
||||||
|
$query = $this->db->query($sqlQ);
|
||||||
|
$data['test_data'] = $query->getResultArray();
|
||||||
|
|
||||||
|
if (count($data['test_data']) == 1) {
|
||||||
|
$data['test_data'][0]['password'] = '**REMOVED**';
|
||||||
|
$member_id = $data['test_data'][0]['id'];
|
||||||
|
return $inx = [
|
||||||
|
'session_token' => $this->generateSession($member_id),
|
||||||
|
'member_id'=> $member_id,
|
||||||
|
'profile' => $data['test_data'],
|
||||||
|
'settings' => [],
|
||||||
|
'preferences' => [],
|
||||||
|
'status' => 1,
|
||||||
|
'raw_data' => $in,
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
return $inx = [
|
||||||
|
'session_token' => '',
|
||||||
|
'settings' => [],
|
||||||
|
'preferences' => [],
|
||||||
|
'status' => 0,
|
||||||
|
'raw_data' => $in,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function generateSession()
|
||||||
|
{
|
||||||
|
// do the seesion stuffs here - set up all permissions
|
||||||
|
$tk='';
|
||||||
|
for($i=1; $i<20; $i++){
|
||||||
|
$tk .= rand(11111, 99999);
|
||||||
|
}
|
||||||
|
return $tk;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user