Skip to content

Commit

Permalink
- #84 CREST Login (WIP)
Browse files Browse the repository at this point in the history
- New CREST controller
- Database restructuring
- improved type-casting for some controller functions
- New login process
- Fixed some bugs during the setup process (/setup root)
- Added CREST request caching by response headers
  • Loading branch information
exodus4d committed Mar 12, 2016
1 parent 6fae608 commit 7e94ec4
Show file tree
Hide file tree
Showing 39 changed files with 1,794 additions and 1,455 deletions.
23 changes: 14 additions & 9 deletions app/environment.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

[ENVIRONMENT]
; project environment (DEVELOP, PRODUCTION).
; This effects: DB connection, Mail-Server connection
; This effects: DB connection, Mail-Server, SSO, CREST configurations in this file
; configuration below
SERVER = DEVELOP

[ENVIRONMENT.DEVELOP]
; base dir (Default: "auto-detect"
; base dir (Default: "auto-detect")
BASE =
; deployment URL e.g. http://localhost
; deployment URL (e.g. http://localhost)
URL = http://pathfinder.local
; Verbosity level of the stack trace
; level of debug/error stack trace
DEBUG = 3
; main db
DB_DNS = mysql:host=localhost;port=3306;dbname=
Expand All @@ -25,11 +25,13 @@ DB_CCP_NAME = eve_parallax_min
DB_CCP_USER = root
DB_CCP_PASS =

; CCP SSO settings
; CCP SSO settings (OAuth2) - visit: https://developers.eveonline.com/applications
CCP_CREST_URL = https://api-sisi.testeveonline.com
SSO_CCP_URL = https://sisilogin.testeveonline.com
SSO_CCP_CLIENT_ID =
SSO_CCP_SECRET_KEY =

; SMTP settings. see: https://developers.eveonline.com/applications
; SMTP settings (optional)
SMTP_HOST = localhost
SMTP_PORT = 25
SMTP_SCHEME = ""
Expand All @@ -40,10 +42,11 @@ SMTP_FROM = pathfinder@localhost.com
SMTP_ERROR = pathfinder@localhost.com

[ENVIRONMENT.PRODUCTION]
; base dir (Default: "auto-detect"
BASE = /www/htdocs/www.pathfinder-w.space
; deployment URL
; deployment URL (e.g. https://www.pathfinder-w.space)
URL = https://www.pathfinder-w.space
; Verbosity level of the stack trace
; level of debug/error stack trace
DEBUG = 0
; main db
DB_DNS = mysql:host=localhost;port=3306;dbname=
Expand All @@ -58,10 +61,12 @@ DB_CCP_USER =
DB_CCP_PASS =

; CCP SSO settings
CCP_CREST_URL = https://crest-tq.eveonline.com
SSO_CCP_URL = https://login.eveonline.com
SSO_CCP_CLIENT_ID =
SSO_CCP_SECRET_KEY =

; SMTP settings
; SMTP settings (optional)
SMTP_HOST = localhost
SMTP_PORT = 25
SMTP_SCHEME = TLS
Expand Down
17 changes: 9 additions & 8 deletions app/main/controller/accesscontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@
*/

namespace Controller;
use Controller\Api as Api;
use Model;

class AccessController extends Controller {

/**
* event handler
* @param $f3
* @param \Base $f3
*/
function beforeroute($f3) {
function beforeroute(\Base $f3) {
parent::beforeroute($f3);

// Any CMS route of a child class of this one, requires a
// valid logged in user!
$loginCheck = $this->_checkLogIn();
$loginCheck = $this->checkLogIn($f3);

if( !$loginCheck ){
// no user found or LogIn timer expired
Expand All @@ -30,16 +31,16 @@ function beforeroute($f3) {

/**
* checks weather a user is currently logged in
* @param \Base $f3
* @return bool
*/
private function _checkLogIn(){

private function checkLogIn($f3){
$loginCheck = false;

if($this->f3->get('SESSION.user.time') > 0){
if($f3->get(Api\User::SESSION_KEY_CHARACTER_TIME) > 0){
// check logIn time
$logInTime = new \DateTime();
$logInTime->setTimestamp($this->f3->get('SESSION.user.time'));
$logInTime->setTimestamp( $f3->get(Api\User::SESSION_KEY_CHARACTER_TIME) );
$now = new \DateTime();

$timeDiff = $now->diff($logInTime);
Expand All @@ -48,7 +49,7 @@ private function _checkLogIn(){
$minutes += $timeDiff->h * 60;
$minutes += $timeDiff->i;

if($minutes <= $this->f3->get('PATHFINDER.TIMER.LOGGED')){
if($minutes <= $f3->get('PATHFINDER.TIMER.LOGGED')){
$loginCheck = true;
}
}
Expand Down
40 changes: 25 additions & 15 deletions app/main/controller/api/connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,26 @@
*/

namespace Controller\Api;
use Controller;
use Model;

class Connection extends \Controller\AccessController{
class Connection extends Controller\AccessController{

/**
* @param $f3
* @param \Base $f3
*/
function beforeroute($f3) {

parent::beforeroute($f3);

function beforeroute(\Base $f3) {
// set header for all routes
header('Content-type: application/json');
parent::beforeroute($f3);
}

/**
* save a new connection or updates an existing (drag/drop) between two systems
* if a connection is changed (drag&drop) to another system. -> this function is called for update
* @param $f3
* @param \Base $f3
*/
public function save($f3){
public function save(\Base $f3){
$postData = (array)$f3->get('POST');
$newConnectionData = [];

Expand All @@ -38,10 +37,15 @@ public function save($f3){
$mapData = (array)$postData['mapData'];
$connectionData = (array)$postData['connectionData'];

$user = $this->_getUser();
$activeCharacter = $this->getCharacter();

if($activeCharacter){
$user = $activeCharacter->getUser();

if($user){
// get map model and check map access
/**
* @var Model\MapModel $map
*/
$map = Model\BasicModel::getNew('MapModel');
$map->getById( (int)$mapData['id'] );

Expand Down Expand Up @@ -90,16 +94,22 @@ public function save($f3){
echo json_encode($newConnectionData);
}

public function delete($f3){
/**
* delete connection
* @param \Base $f3
* @throws \Exception
*/
public function delete(\Base $f3){
$connectionIds = $f3->get('POST.connectionIds');
$activeCharacter = $this->getCharacter();

$user = $this->_getUser();
/**
* @var Model\ConnectionModel $connection
*/
$connection = Model\BasicModel::getNew('ConnectionModel');

foreach($connectionIds as $connectionId){

$connection->getById($connectionId);
$connection->delete($user);
$connection->delete( $activeCharacter->getUser() );

$connection->reset();
}
Expand Down
Loading

0 comments on commit 7e94ec4

Please sign in to comment.