[add] Login endpoint

This commit is contained in:
2018-08-05 03:40:05 -06:00
parent 3fe49d894d
commit 8b09f75d3a
7 changed files with 113 additions and 5 deletions

View File

@@ -11,4 +11,35 @@ $app->get('/[{name}]', function (Request $request, Response $response, array $ar
// Render index view
return $this->renderer->render($response, 'index.phtml', $args);
});
$app->post('/api/session/login', function ($request, $response) {
$RequestData = $request->getParsedBody();
$data = $this->sessionApplication->newSession($RequestData['userName'], $RequestData['password']);
return $response->withStatus(200)
->withHeader('Content-Type', 'application/json')
->write(json_encode($data));
});
$app->get('/api/encrypt/{string}', function (Request $request, Response $response, array $args) {
return $this->cryptographyService->encryptString($args['string']);
});
$app->get('/api/decrypt/{string}', function (Request $request, Response $response, array $args) {
return $this->cryptographyService->decryptString($args['string']);
});
$app->get('/api/encrypt/password/{string}', function (Request $request, Response $response, array $args) {
return $this->cryptographyService->encryptPassword($args['string']);
});
$app->get('/api/decrypt/password/{string}', function (Request $request, Response $response, array $args) {
$cosa = $this->cryptographyService->decryptPassword("pablso", "$2y$12$4T.gxWkQNPPFQau7ghfiQegdJQOm1yLTlbOTvcI3AizyqF/JSHr06");
if ($cosa){
return "yea";
}
});