@@ -7,7 +7,6 @@ |
||
| 7 | 7 | use Symfony\Component\HttpFoundation\JsonResponse; |
| 8 | 8 | use Silex\Application; |
| 9 | 9 | use Silex\Api\ControllerProviderInterface; |
| 10 | -use Monolog\Logger; |
|
| 11 | 10 | use RedBeanPHP\Facade as R; |
| 12 | 11 | |
| 13 | 12 | class SecurityController implements ControllerProviderInterface |
@@ -31,41 +31,41 @@ discard block |
||
| 31 | 31 | { |
| 32 | 32 | /*TODO remove this line in producton DBG DATA {"authMode":"Email","email":"[email protected]","name":"ugo","surname":"ugo","password":"cane"}*/ |
| 33 | 33 | $data = json_decode($request->getContent(), true); |
| 34 | - if($data === NULL){ |
|
| 35 | - $headers=[]; |
|
| 34 | + if ($data === NULL) { |
|
| 35 | + $headers = []; |
|
| 36 | 36 | $response = JsonResponse::create($res, 403, $headers)->setSharedMaxAge(300); |
| 37 | 37 | return $response; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | $authMode = $data['authMode']; |
| 41 | 41 | |
| 42 | - if($authMode === 'Email'){ |
|
| 42 | + if ($authMode === 'Email') { |
|
| 43 | 43 | $email = $data['email']; |
| 44 | 44 | $password = $data['password']; |
| 45 | 45 | $name = $data['name']; |
| 46 | 46 | $surname = $data['surname']; |
| 47 | - $user = R::findOne('user',"WHERE email = ? AND name = ? AND surname = ?",[$email,$name,$surname]); |
|
| 48 | - if($user->pwd === hash("sha256",$user->salt.$password)){ |
|
| 47 | + $user = R::findOne('user', "WHERE email = ? AND name = ? AND surname = ?", [$email, $name, $surname]); |
|
| 48 | + if ($user->pwd === hash("sha256", $user->salt.$password)) { |
|
| 49 | 49 | //LOGGED IN! |
| 50 | 50 | $this->app['session']->set('user', ['id' => $user->id]); |
| 51 | - $headers=[]; |
|
| 51 | + $headers = []; |
|
| 52 | 52 | $res = [ |
| 53 | - "token"=>"blablabla",//TODO CREATE token |
|
| 53 | + "token"=>"blablabla", //TODO CREATE token |
|
| 54 | 54 | "clientId"=>$user->id |
| 55 | 55 | ]; |
| 56 | 56 | $response = JsonResponse::create($res, 200, $headers)->setSharedMaxAge(300); |
| 57 | - }else{ |
|
| 58 | - $headers=[]; |
|
| 57 | + }else { |
|
| 58 | + $headers = []; |
|
| 59 | 59 | $res = [ |
| 60 | 60 | "errore"=>"sbagliato password o user" //TODO roba |
| 61 | 61 | ]; |
| 62 | 62 | $response = JsonResponse::create($res, 401, $headers)->setSharedMaxAge(300); |
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | - else{ |
|
| 65 | + else { |
|
| 66 | 66 | //Facebook Redirect |
| 67 | 67 | } |
| 68 | - return $response;// JsonResponse::create($output, 200, $headers)->setSharedMaxAge(300); |
|
| 68 | + return $response; // JsonResponse::create($output, 200, $headers)->setSharedMaxAge(300); |
|
| 69 | 69 | } |
| 70 | 70 | public function logout(Request $request) |
| 71 | 71 | { |
@@ -78,19 +78,19 @@ discard block |
||
| 78 | 78 | } |
| 79 | 79 | public function confirm(Request $request) |
| 80 | 80 | { |
| 81 | - $confirmKey= $request->request->get('confirmKey'); |
|
| 82 | - $verify = R::findOne('verify',"WHERE key = ?",[$confirmKey]); |
|
| 83 | - if (!$bean->id){ |
|
| 81 | + $confirmKey = $request->request->get('confirmKey'); |
|
| 82 | + $verify = R::findOne('verify', "WHERE key = ?", [$confirmKey]); |
|
| 83 | + if (!$bean->id) { |
|
| 84 | 84 | //TODO mettere un controllo agli IP che forzano le richieste di token falsi |
| 85 | 85 | $response = "<html><head></head><body>Token non esistente!</body></html>"; |
| 86 | - }else{ |
|
| 87 | - if(strtotime($verify->inserttime) < strtotime("-15 minutes")){ |
|
| 88 | - $user = R::load('user',$verify->user); |
|
| 89 | - $user->status="enabled"; |
|
| 90 | - $user->updatetime=date('Y-m-d H:i:s'); |
|
| 86 | + }else { |
|
| 87 | + if (strtotime($verify->inserttime) < strtotime("-15 minutes")) { |
|
| 88 | + $user = R::load('user', $verify->user); |
|
| 89 | + $user->status = "enabled"; |
|
| 90 | + $user->updatetime = date('Y-m-d H:i:s'); |
|
| 91 | 91 | $id = R::store($user); |
| 92 | 92 | $response = "<html><head></head><body>Account attivato complimenti!</body></html>"; |
| 93 | - }else{ |
|
| 93 | + }else { |
|
| 94 | 94 | $response = "<html><head></head><body>Impossibile attivare account inserire mail e password per richiedere un nuovo token!</body></html>"; |
| 95 | 95 | } |
| 96 | 96 | } |
@@ -54,15 +54,14 @@ discard block |
||
| 54 | 54 | "clientId"=>$user->id |
| 55 | 55 | ]; |
| 56 | 56 | $response = JsonResponse::create($res, 200, $headers)->setSharedMaxAge(300); |
| 57 | - }else{ |
|
| 57 | + } else{ |
|
| 58 | 58 | $headers=[]; |
| 59 | 59 | $res = [ |
| 60 | 60 | "errore"=>"sbagliato password o user" //TODO roba |
| 61 | 61 | ]; |
| 62 | 62 | $response = JsonResponse::create($res, 401, $headers)->setSharedMaxAge(300); |
| 63 | 63 | } |
| 64 | - } |
|
| 65 | - else{ |
|
| 64 | + } else{ |
|
| 66 | 65 | //Facebook Redirect |
| 67 | 66 | } |
| 68 | 67 | return $response;// JsonResponse::create($output, 200, $headers)->setSharedMaxAge(300); |
@@ -83,14 +82,14 @@ discard block |
||
| 83 | 82 | if (!$bean->id){ |
| 84 | 83 | //TODO mettere un controllo agli IP che forzano le richieste di token falsi |
| 85 | 84 | $response = "<html><head></head><body>Token non esistente!</body></html>"; |
| 86 | - }else{ |
|
| 85 | + } else{ |
|
| 87 | 86 | if(strtotime($verify->inserttime) < strtotime("-15 minutes")){ |
| 88 | 87 | $user = R::load('user',$verify->user); |
| 89 | 88 | $user->status="enabled"; |
| 90 | 89 | $user->updatetime=date('Y-m-d H:i:s'); |
| 91 | 90 | $id = R::store($user); |
| 92 | 91 | $response = "<html><head></head><body>Account attivato complimenti!</body></html>"; |
| 93 | - }else{ |
|
| 92 | + } else{ |
|
| 94 | 93 | $response = "<html><head></head><body>Impossibile attivare account inserire mail e password per richiedere un nuovo token!</body></html>"; |
| 95 | 94 | } |
| 96 | 95 | } |
@@ -3,11 +3,9 @@ |
||
| 3 | 3 | namespace BitPrepared\Bundle\D1b0Workspace\Controller\V1; |
| 4 | 4 | |
| 5 | 5 | use Symfony\Component\HttpFoundation\Request; |
| 6 | -use Symfony\Component\HttpFoundation\Response; |
|
| 7 | 6 | use Symfony\Component\HttpFoundation\JsonResponse; |
| 8 | 7 | use Silex\Application; |
| 9 | 8 | use Silex\Api\ControllerProviderInterface; |
| 10 | -use Monolog\Logger; |
|
| 11 | 9 | use RedBeanPHP\Facade as R; |
| 12 | 10 | |
| 13 | 11 | class WorkspaceController implements ControllerProviderInterface |
@@ -21,19 +21,19 @@ discard block |
||
| 21 | 21 | $factory = $app['controllers_factory']; |
| 22 | 22 | # il mount point e' precedente e non serve prima |
| 23 | 23 | $this->app['db']; |
| 24 | - R::fancyDebug( TRUE ); |
|
| 24 | + R::fancyDebug(TRUE); |
|
| 25 | 25 | $factory->get('/', array($this, 'getWorkspaceList')); |
| 26 | 26 | $factory->post('/', array($this, 'createWorkspace')); |
| 27 | 27 | return $factory; |
| 28 | 28 | } |
| 29 | - public function getSessionId(){ |
|
| 30 | - $user_id=$this->app['session']->get('user')['id']; |
|
| 29 | + public function getSessionId() { |
|
| 30 | + $user_id = $this->app['session']->get('user')['id']; |
|
| 31 | 31 | return $user_id; |
| 32 | 32 | } |
| 33 | 33 | public function getWorkspaceList(Request $request) |
| 34 | 34 | { |
| 35 | - $user_id=$this->getSessionId(); |
|
| 36 | - $workspaces = R::getAll("SELECT ws.id, |
|
| 35 | + $user_id = $this->getSessionId(); |
|
| 36 | + $workspaces = R::getAll("SELECT ws.id, |
|
| 37 | 37 | ws.title, |
| 38 | 38 | ws.description, |
| 39 | 39 | ws.environment, |
@@ -42,14 +42,14 @@ discard block |
||
| 42 | 42 | LEFT JOIN workspace AS ws |
| 43 | 43 | ON uws.workspace = ws.id |
| 44 | 44 | WHERE uws.user = ?",[$user_id]); |
| 45 | - $list=[]; |
|
| 46 | - foreach($workspaces as $ws){ |
|
| 47 | - array_push($list,[ |
|
| 45 | + $list = []; |
|
| 46 | + foreach ($workspaces as $ws) { |
|
| 47 | + array_push($list, [ |
|
| 48 | 48 | "id"=>$ws['id'], |
| 49 | 49 | "title"=>$ws['title'], |
| 50 | 50 | "description"=>$ws['description'], |
| 51 | 51 | "environment"=>$ws['environment'], |
| 52 | - "point"=>0,//TODO fare una view con i point già calcolati per il ws |
|
| 52 | + "point"=>0, //TODO fare una view con i point già calcolati per il ws |
|
| 53 | 53 | "completed"=>$ws['completed'], |
| 54 | 54 | ]); |
| 55 | 55 | } |
@@ -59,13 +59,13 @@ discard block |
||
| 59 | 59 | } |
| 60 | 60 | public function createWorkspace(Request $request) |
| 61 | 61 | { |
| 62 | - $user_id=$this->getSessionId(); |
|
| 63 | - $counter=0; |
|
| 62 | + $user_id = $this->getSessionId(); |
|
| 63 | + $counter = 0; |
|
| 64 | 64 | $data = json_decode($request->getContent(), true); |
| 65 | 65 | //TODO validate json_decode |
| 66 | - $title=$data['title']; |
|
| 67 | - $description=$data['description']; |
|
| 68 | - $environment=$data['environment']; |
|
| 66 | + $title = $data['title']; |
|
| 67 | + $description = $data['description']; |
|
| 68 | + $environment = $data['environment']; |
|
| 69 | 69 | |
| 70 | 70 | $patrol = $data['team']['patrol']; |
| 71 | 71 | $unit = $data['team']['unit']; |
@@ -73,46 +73,46 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | //save the workspace get id |
| 75 | 75 | $ws = R::dispense("workspace"); |
| 76 | - $ws->title=$title; |
|
| 77 | - $ws->description=$description; |
|
| 78 | - $ws->environment=$environment; |
|
| 79 | - $ws->completed=false; |
|
| 80 | - $ws->inserttime=date('Y-m-d H:i:s'); |
|
| 81 | - $ws->lastupdatetime=date('Y-m-d H:i:s'); |
|
| 76 | + $ws->title = $title; |
|
| 77 | + $ws->description = $description; |
|
| 78 | + $ws->environment = $environment; |
|
| 79 | + $ws->completed = false; |
|
| 80 | + $ws->inserttime = date('Y-m-d H:i:s'); |
|
| 81 | + $ws->lastupdatetime = date('Y-m-d H:i:s'); |
|
| 82 | 82 | $id = R::store($ws); |
| 83 | 83 | |
| 84 | 84 | //save the team |
| 85 | 85 | $team = R::dispense("team"); |
| 86 | - $team->workspace=$id; |
|
| 87 | - $team->patrol=$patrol; |
|
| 88 | - $team->unit=$unit; |
|
| 89 | - $team->group=$group; |
|
| 86 | + $team->workspace = $id; |
|
| 87 | + $team->patrol = $patrol; |
|
| 88 | + $team->unit = $unit; |
|
| 89 | + $team->group = $group; |
|
| 90 | 90 | $team_id = R::store($team); |
| 91 | 91 | |
| 92 | 92 | //create a phantom part to add badge |
| 93 | 93 | $part = R::dispense("part"); |
| 94 | - $part->workspace=$id; |
|
| 95 | - $part->user=$user_id; |
|
| 96 | - $part->inserttime=date('Y-m-d H:i:s'); |
|
| 97 | - $part->lastupdatetime=date('Y-m-d H:i:s'); |
|
| 98 | - $part->totalpoint=0; |
|
| 94 | + $part->workspace = $id; |
|
| 95 | + $part->user = $user_id; |
|
| 96 | + $part->inserttime = date('Y-m-d H:i:s'); |
|
| 97 | + $part->lastupdatetime = date('Y-m-d H:i:s'); |
|
| 98 | + $part->totalpoint = 0; |
|
| 99 | 99 | $part_id = R::store($part); |
| 100 | 100 | |
| 101 | 101 | //add the badge to the project |
| 102 | - foreach($data['badges'] as $badge_id){ |
|
| 102 | + foreach ($data['badges'] as $badge_id) { |
|
| 103 | 103 | //TODO insert those badge as first hidden post |
| 104 | 104 | $pb = R::dispense("partbadge"); |
| 105 | - $pb->badge=$badge_id; |
|
| 106 | - $pb->part=$part_id; |
|
| 107 | - $pb->inserttime=date('Y-m-d H:i:s'); |
|
| 105 | + $pb->badge = $badge_id; |
|
| 106 | + $pb->part = $part_id; |
|
| 107 | + $pb->inserttime = date('Y-m-d H:i:s'); |
|
| 108 | 108 | $tmp = R::store($pb); |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | //add the workspace created to the user as owner |
| 112 | 112 | $usw = R::dispense("userworkspace"); |
| 113 | - $usw->user=$user_id; |
|
| 114 | - $usw->workspace=$id; |
|
| 115 | - $usw->inserttime=date('Y-m-d H:i:s'); |
|
| 113 | + $usw->user = $user_id; |
|
| 114 | + $usw->workspace = $id; |
|
| 115 | + $usw->inserttime = date('Y-m-d H:i:s'); |
|
| 116 | 116 | R::store($usw); |
| 117 | 117 | |
| 118 | 118 | $res = ["id" => $id]; |
@@ -11,13 +11,11 @@ |
||
| 11 | 11 | use Silex\Application; |
| 12 | 12 | use Symfony\Component\HttpFoundation\Request; |
| 13 | 13 | use Symfony\Component\HttpFoundation\Response; |
| 14 | -use Symfony\Component\HttpFoundation\JsonResponse; |
|
| 15 | 14 | use Silex\Provider\MonologServiceProvider; |
| 16 | 15 | use Ivoba\Silex\RedBeanServiceProvider; |
| 17 | 16 | use Silex\Provider\SessionServiceProvider; |
| 18 | 17 | use Carbon\Carbon; |
| 19 | 18 | use Monolog\Logger; |
| 20 | -use RedBeanPHP\Facade as R; |
|
| 21 | 19 | |
| 22 | 20 | // FIXME va messo nel php.ini |
| 23 | 21 | date_default_timezone_set('Europe/Rome'); |
@@ -37,14 +37,14 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | // @see: http://silex.sensiolabs.org/doc/providers/monolog.html |
| 39 | 39 | $app->register(new MonologServiceProvider(), array( |
| 40 | - "monolog.logfile" => ROOT_PATH . "/storage/logs/development_" . Carbon::now('Europe/Rome')->format("Y-m-d") . ".log", |
|
| 40 | + "monolog.logfile" => ROOT_PATH."/storage/logs/development_".Carbon::now('Europe/Rome')->format("Y-m-d").".log", |
|
| 41 | 41 | "monolog.level" => $app["log.level"], |
| 42 | 42 | "monolog.name" => "application" |
| 43 | 43 | )); |
| 44 | 44 | |
| 45 | 45 | // @see: https://github.com/ivoba/redbean-service-provider |
| 46 | 46 | //'mysql:host=localhost;dbname=mydatabase', 'user', 'password' |
| 47 | -$app->register(new RedBeanServiceProvider(), array('db.options' => array( 'dsn' => 'sqlite:'.ROOT_PATH.'/../../database/workspace.sqlite' ))); |
|
| 47 | +$app->register(new RedBeanServiceProvider(), array('db.options' => array('dsn' => 'sqlite:'.ROOT_PATH.'/../../database/workspace.sqlite'))); |
|
| 48 | 48 | $app->register(new SessionServiceProvider()); |
| 49 | 49 | |
| 50 | 50 | // production (X-Forwarded-For*) |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | Request::enableHttpMethodParameterOverride(); |
| 53 | 53 | |
| 54 | 54 | //handling CORS preflight request |
| 55 | -$app->before(function (Request $request) { |
|
| 55 | +$app->before(function(Request $request) { |
|
| 56 | 56 | if ($request->getMethod() === "OPTIONS") { |
| 57 | 57 | $response = new Response(); |
| 58 | 58 | $response->headers->set("Access-Control-Allow-Origin", "*"); |
@@ -64,12 +64,12 @@ discard block |
||
| 64 | 64 | }, Application::EARLY_EVENT); |
| 65 | 65 | |
| 66 | 66 | //handling CORS respons with right headers |
| 67 | -$app->after(function (Request $request, Response $response) { |
|
| 67 | +$app->after(function(Request $request, Response $response) { |
|
| 68 | 68 | $response->headers->set("Access-Control-Allow-Origin", "*"); |
| 69 | 69 | $response->headers->set("Access-Control-Allow-Methods", "GET,POST,PUT,DELETE,OPTIONS"); |
| 70 | 70 | }); |
| 71 | 71 | |
| 72 | -$app->error(function (\Exception $e, Request $request, $code) use ($app) { |
|
| 72 | +$app->error(function(\Exception $e, Request $request, $code) use ($app) { |
|
| 73 | 73 | // this handler will handle \Exception |
| 74 | 74 | $app['monolog']->addError($e->getMessage()); |
| 75 | 75 | $app['monolog']->addError($e->getTraceAsString()); |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | |
| 14 | 14 | // custom string representation of object |
| 15 | 15 | public function __toString() { |
| 16 | - return __CLASS__ . ": [{$this->code}]: {$this->message}\n"; |
|
| 16 | + return __CLASS__.": [{$this->code}]: {$this->message}\n"; |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | } |
@@ -24,24 +24,24 @@ discard block |
||
| 24 | 24 | $this->app['db']; |
| 25 | 25 | //R::fancyDebug( TRUE ); |
| 26 | 26 | $factory->post('/signup', array($this, 'signup')); |
| 27 | - $factory->get('/{id}', array($this, 'get'))->before([$this,'isSession']); |
|
| 28 | - $factory->post('/{id}/badge', array($this, 'postBadge'))->before([$this,'isSession']); |
|
| 29 | - $factory->get('/{id}/badge/{id_badge}', array($this, 'getBadge'))->before([$this,'isSession']); |
|
| 30 | - $factory->patch('/{id}/badge/{id_badge}/completed', array($this, 'markBadgeAsCompleted'))->before([$this,'isSession']); |
|
| 31 | - $factory->delete('/{id}/badge/{id_badge}', array($this, 'deleteUserBadge'))->before([$this,'isSession']); |
|
| 32 | - $factory->get('/{id}/ticket', array($this, 'getTicket'))->before([$this,'isSession']); |
|
| 27 | + $factory->get('/{id}', array($this, 'get'))->before([$this, 'isSession']); |
|
| 28 | + $factory->post('/{id}/badge', array($this, 'postBadge'))->before([$this, 'isSession']); |
|
| 29 | + $factory->get('/{id}/badge/{id_badge}', array($this, 'getBadge'))->before([$this, 'isSession']); |
|
| 30 | + $factory->patch('/{id}/badge/{id_badge}/completed', array($this, 'markBadgeAsCompleted'))->before([$this, 'isSession']); |
|
| 31 | + $factory->delete('/{id}/badge/{id_badge}', array($this, 'deleteUserBadge'))->before([$this, 'isSession']); |
|
| 32 | + $factory->get('/{id}/ticket', array($this, 'getTicket'))->before([$this, 'isSession']); |
|
| 33 | 33 | return $factory; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - public function isSession(Request $request,Application $app){ |
|
| 37 | - if($this->app['session']->has('user') !== true){ |
|
| 38 | - throw new UnauthorizedException("errore",1); |
|
| 36 | + public function isSession(Request $request, Application $app) { |
|
| 37 | + if ($this->app['session']->has('user') !== true) { |
|
| 38 | + throw new UnauthorizedException("errore", 1); |
|
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public function get($id, Request $request) |
| 43 | 43 | { |
| 44 | - $user = R::findOne('user', 'id = ?',["$id"]); |
|
| 44 | + $user = R::findOne('user', 'id = ?', ["$id"]); |
|
| 45 | 45 | $headers = []; |
| 46 | 46 | |
| 47 | 47 | $output = [ |
@@ -52,9 +52,9 @@ discard block |
||
| 52 | 52 | 'skills'=>'', |
| 53 | 53 | ]; |
| 54 | 54 | |
| 55 | - $badges = R::findAll('userbadgecomplete','WHERE user = ?',[$id]); |
|
| 56 | - $badgeList=[]; |
|
| 57 | - foreach( $badges as $badge){ |
|
| 55 | + $badges = R::findAll('userbadgecomplete', 'WHERE user = ?', [$id]); |
|
| 56 | + $badgeList = []; |
|
| 57 | + foreach ($badges as $badge) { |
|
| 58 | 58 | array_push($badgeList, |
| 59 | 59 | [ |
| 60 | 60 | 'badge'=>[ |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | ] |
| 69 | 69 | ); |
| 70 | 70 | } |
| 71 | - $output['skills']=$badgeList; |
|
| 71 | + $output['skills'] = $badgeList; |
|
| 72 | 72 | return JsonResponse::create($output, 200, $headers)->setSharedMaxAge(300); |
| 73 | 73 | } |
| 74 | 74 | |
@@ -82,35 +82,35 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | $authMode = $data['authMode']; |
| 84 | 84 | $id = -1; |
| 85 | - if($authMode === 'Email'){ |
|
| 85 | + if ($authMode === 'Email') { |
|
| 86 | 86 | /* |
| 87 | 87 | $user = R::dispense('user'); |
| 88 | 88 | $user->authMode=$data['authMode']; |
| 89 | 89 | $user->name=$data['name']; |
| 90 | 90 | $user->surname=$data['surname']; |
| 91 | 91 | $user->surname=$data['surname'];*/ |
| 92 | - try{ |
|
| 92 | + try { |
|
| 93 | 93 | $user = R::dispense('user'); |
| 94 | 94 | //$user->import($data); |
| 95 | 95 | $size = mcrypt_get_iv_size(MCRYPT_CAST_256, MCRYPT_MODE_CFB); |
| 96 | 96 | $iv = mcrypt_create_iv($size, MCRYPT_DEV_RANDOM); |
| 97 | 97 | $user->salt = $iv; |
| 98 | - $user->pwd = hash("sha256",$iv.$data['password']); |
|
| 98 | + $user->pwd = hash("sha256", $iv.$data['password']); |
|
| 99 | 99 | $user->status = "checking"; |
| 100 | 100 | //$user->id="11"; |
| 101 | - $user->name=$data['name']; |
|
| 102 | - $user->email=$data['email']; |
|
| 103 | - $user->surname=$data['surname']; |
|
| 104 | - $user->authmode=$data['authMode']; |
|
| 105 | - $user->inserttime=date('Y-m-d H:i:s'); |
|
| 106 | - $user->updatetime=date('Y-m-d G:i:s'); |
|
| 101 | + $user->name = $data['name']; |
|
| 102 | + $user->email = $data['email']; |
|
| 103 | + $user->surname = $data['surname']; |
|
| 104 | + $user->authmode = $data['authMode']; |
|
| 105 | + $user->inserttime = date('Y-m-d H:i:s'); |
|
| 106 | + $user->updatetime = date('Y-m-d G:i:s'); |
|
| 107 | 107 | $id = R::store($user); |
| 108 | 108 | $res = (object)["id" => $id]; |
| 109 | - }catch(Exception $e){ |
|
| 109 | + }catch (Exception $e) { |
|
| 110 | 110 | echo $e; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - }else{ |
|
| 113 | + }else { |
|
| 114 | 114 | |
| 115 | 115 | } |
| 116 | 116 | |
@@ -119,16 +119,16 @@ discard block |
||
| 119 | 119 | return JsonResponse::create($res, 200, $headers)->setSharedMaxAge(300); |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - public function postBadge($id,Request $request) |
|
| 122 | + public function postBadge($id, Request $request) |
|
| 123 | 123 | { |
| 124 | 124 | //TODO valiadre id in funzione della sessione utente (altrimenti chiunque aggiunge badge a chiunque) |
| 125 | 125 | $data = json_decode($request->getContent(), true); |
| 126 | 126 | |
| 127 | 127 | $userbadge = R::dispense('userbadge'); |
| 128 | - $userbadge->user=$id; |
|
| 129 | - $userbadge->badge=$data['id']; |
|
| 130 | - $userbadge->inserttime=date('Y-m-d H:i:s'); |
|
| 131 | - $userbadge->updatetime=date('Y-m-d H:i:s'); |
|
| 128 | + $userbadge->user = $id; |
|
| 129 | + $userbadge->badge = $data['id']; |
|
| 130 | + $userbadge->inserttime = date('Y-m-d H:i:s'); |
|
| 131 | + $userbadge->updatetime = date('Y-m-d H:i:s'); |
|
| 132 | 132 | $id = R::store($userbadge); |
| 133 | 133 | |
| 134 | 134 | $res = (object)["id" => $id]; |
@@ -136,9 +136,9 @@ discard block |
||
| 136 | 136 | return JsonResponse::create($res, 200, $headers)->setSharedMaxAge(300); |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - public function getBadge($id,$id_badge,Request $request) |
|
| 139 | + public function getBadge($id, $id_badge, Request $request) |
|
| 140 | 140 | { |
| 141 | - $badge = R::findOne('userbadgecomplete','WHERE user = ? AND badge = ?',[$id,$id_badge]); |
|
| 141 | + $badge = R::findOne('userbadgecomplete', 'WHERE user = ? AND badge = ?', [$id, $id_badge]); |
|
| 142 | 142 | $res = [ |
| 143 | 143 | 'badge'=>[ |
| 144 | 144 | 'id'=>$badge['badge'], |
@@ -152,21 +152,21 @@ discard block |
||
| 152 | 152 | $headers = []; |
| 153 | 153 | return JsonResponse::create($res, 200, $headers)->setSharedMaxAge(300); |
| 154 | 154 | } |
| 155 | - public function markBadgeAsCompleted($id,$id_badge,Request $request){ |
|
| 156 | - $userbadge = R::load('userbadge',$id_badge); |
|
| 157 | - $userbadge->user=$id; |
|
| 158 | - $userbadge->badge=$id_badge; |
|
| 159 | - $userbadge->updatetime=date('Y-m-d H:i:s'); |
|
| 160 | - $userbadge->completed=1; |
|
| 155 | + public function markBadgeAsCompleted($id, $id_badge, Request $request) { |
|
| 156 | + $userbadge = R::load('userbadge', $id_badge); |
|
| 157 | + $userbadge->user = $id; |
|
| 158 | + $userbadge->badge = $id_badge; |
|
| 159 | + $userbadge->updatetime = date('Y-m-d H:i:s'); |
|
| 160 | + $userbadge->completed = 1; |
|
| 161 | 161 | $id = R::store($userbadge); |
| 162 | 162 | $res = (object)["id" => $id]; |
| 163 | 163 | $headers = []; |
| 164 | 164 | return JsonResponse::create($res, 200, $headers)->setSharedMaxAge(300); |
| 165 | 165 | } |
| 166 | - public function deleteUserBadge($id,$id_badge,Request $request){ |
|
| 167 | - $userbadge = R::load('userbadge',$id_badge); |
|
| 168 | - $userbadge->deleted=1; |
|
| 169 | - $userbadge->updatetime=date('Y-m-d H:i:s'); |
|
| 166 | + public function deleteUserBadge($id, $id_badge, Request $request) { |
|
| 167 | + $userbadge = R::load('userbadge', $id_badge); |
|
| 168 | + $userbadge->deleted = 1; |
|
| 169 | + $userbadge->updatetime = date('Y-m-d H:i:s'); |
|
| 170 | 170 | $id = R::store($userbadge); |
| 171 | 171 | $headers = []; |
| 172 | 172 | $response = new Response(); |
@@ -175,12 +175,12 @@ discard block |
||
| 175 | 175 | $response->setSharedMaxAge(300); |
| 176 | 176 | return $response; |
| 177 | 177 | } |
| 178 | - public function getTicket($id,Request $request){ |
|
| 179 | - $ticketRaw = R::findAll('ticket','WHERE user = ? AND (NOT status = "closed")',[$id]); |
|
| 178 | + public function getTicket($id, Request $request) { |
|
| 179 | + $ticketRaw = R::findAll('ticket', 'WHERE user = ? AND (NOT status = "closed")', [$id]); |
|
| 180 | 180 | |
| 181 | - $tickets=[]; |
|
| 182 | - foreach($ticketRaw as $ticket){ |
|
| 183 | - array_push($tickets,[ |
|
| 181 | + $tickets = []; |
|
| 182 | + foreach ($ticketRaw as $ticket) { |
|
| 183 | + array_push($tickets, [ |
|
| 184 | 184 | "id"=>$ticket['id'], |
| 185 | 185 | "message"=>$ticket['message'], |
| 186 | 186 | "url"=>$ticket['url'], |
@@ -106,11 +106,11 @@ |
||
| 106 | 106 | $user->updatetime=date('Y-m-d G:i:s'); |
| 107 | 107 | $id = R::store($user); |
| 108 | 108 | $res = (object)["id" => $id]; |
| 109 | - }catch(Exception $e){ |
|
| 109 | + } catch(Exception $e){ |
|
| 110 | 110 | echo $e; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - }else{ |
|
| 113 | + } else{ |
|
| 114 | 114 | |
| 115 | 115 | } |
| 116 | 116 | |
@@ -32,9 +32,9 @@ |
||
| 32 | 32 | $this->app->log('log info', [], Logger::INFO); //grazie al traits <- da trasformare prima in app |
| 33 | 33 | |
| 34 | 34 | $data = array( |
| 35 | - "workspace" => "OK", |
|
| 36 | - "fileManager" => "OK", |
|
| 37 | - "externalLogin" => "OK" |
|
| 35 | + "workspace" => "OK", |
|
| 36 | + "fileManager" => "OK", |
|
| 37 | + "externalLogin" => "OK" |
|
| 38 | 38 | ); |
| 39 | 39 | |
| 40 | 40 | $headers = []; |