Skip to content

Commit

Permalink
🔨 #118 gerardor authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
Reinaldo Araujo Barreto Junior committed Aug 9, 2022
1 parent 2d23c41 commit b8906a8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
24 changes: 22 additions & 2 deletions controllers/CreateApiRoutesCall.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ public function addNameSpaces($contract = false)
$this->addLine('use Slim\Routing\RouteCollectorProxy as RouteCollectorProxy;');
$this->addLine('use Slim\Factory\AppFactory;');
$this->addBlankLine();
$this->addLine('use api_controllers\Authentication;');
$this->addBlankLine();
$this->addLine('use api_controllers\SysinfoAPI;');
if($contract){
$this->addLine('use api_controllers\{');
Expand Down Expand Up @@ -139,6 +141,25 @@ public function addFactoryAndMiddleware()
$this->addLine(' */');
$this->addLine('$displayErrorDetails = getenv(\'DISPLAY_ERRORS_DETAILS\');');
$this->addLine('$errorMiddleware = $app->addErrorMiddleware($displayErrorDetails, true, true);');
}
//--------------------------------------------------------------------------------------
public function addAuthenticationRouter()
{
$listTableNames = $this->getListTableNames();
$this->addBlankLine();
$this->addBlankLine();
$this->addBlankLine();
$this->addLine('//Entrar na classe Authentication para pegar usuário e senha');
$this->addLine('//Descomentar as linhas que precisam ser autenticadas');
$this->addLine('//$controllerAuthentication = new Authentication($urlChamada);');
foreach ($listTableNames['TABLE_NAME'] as $tableName) {
$this->addLine('//$controllerAuthentication->addPath(\''.$tableName.'\');');
}
$this->addLine('//$app->add($controllerAuthentication->basicAuth());');
$this->addBlankLine();
$this->addBlankLine();
$this->addLine('$app->get($urlChamada.\'sysinfo\', SysinfoAPI::class . \':getInfo\');');
$this->addLine('$app->get($urlChamada.\'auth\', SysinfoAPI::class . \':getInfo\');');
}
//--------------------------------------------------------------------------------------
public function addIndexRoutes()
Expand Down Expand Up @@ -174,8 +195,6 @@ public function addIndexRoutes()
$this->addLine(ESP.'$result = $response->withHeader(\'Content-Type\', \'application/json\');');
$this->addLine(ESP.'return $result;');
$this->addLine('});');
$this->addBlankLine();
$this->addLine('$app->get(\'/sysinfo\', SysinfoAPI::class . \':getInfo\');');
}
//--------------------------------------------------------------------------------------
public function show($print = false)
Expand All @@ -187,6 +206,7 @@ public function show($print = false)
$this->addFactoryAndMiddleware();
$this->addIndexRoutes();
$this->addRouterForTable();
$this->addAuthenticationRouter();
$this->addBlankLine();
$this->addLine('$app->run();');
if ($print) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function getArrayPathIgnore(){

public function addUsers(string $login, string $password){
$this->listUsers[$login] = $password;
}
}
public function getListUsers(){
return $this->listUsers;
}
Expand Down

0 comments on commit b8906a8

Please sign in to comment.