[add] Injecting dependency
This commit is contained in:
parent
2920fdd89b
commit
09f11ebe49
@ -3,6 +3,7 @@
|
|||||||
class SessionApplication{
|
class SessionApplication{
|
||||||
// The to be connection
|
// The to be connection
|
||||||
private $pdo = '';
|
private $pdo = '';
|
||||||
|
private $cryptographyService;
|
||||||
|
|
||||||
function __construct($mysqlSettings, $cryptographyService){
|
function __construct($mysqlSettings, $cryptographyService){
|
||||||
// Services
|
// Services
|
||||||
@ -33,9 +34,13 @@ class SessionApplication{
|
|||||||
|
|
||||||
function newSession($userName, $password){
|
function newSession($userName, $password){
|
||||||
$real = 'slothness';
|
$real = 'slothness';
|
||||||
|
$password = "$2y$12$51mfESaLEGXDT4u9Bd9kiOHEpaJ1Bx4SEcVwsU5K6jVPMNkrnpJAa";
|
||||||
|
|
||||||
if($this->cryptographyService->decryptPassword($real, $password)){
|
if($this->cryptographyService->decryptPassword($real, $password)){
|
||||||
|
return "yea";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
"nah";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,11 +27,8 @@ $container['cryptographyService'] = function ($c) {
|
|||||||
|
|
||||||
// The session application
|
// The session application
|
||||||
$container['sessionApplication'] = function ($c) {
|
$container['sessionApplication'] = function ($c) {
|
||||||
$cryptographySettings = $c->get('settings')['cryptography'];
|
|
||||||
$cryptographyService = new App\Service\CryptographyService($cryptographySettings);
|
|
||||||
|
|
||||||
$mysqlSettings = $c->get('settings')['mysql'];
|
$mysqlSettings = $c->get('settings')['mysql'];
|
||||||
require dirname(__FILE__) . "/../src/application/SessionApplication.php";
|
require dirname(__FILE__) . "/../src/application/SessionApplication.php";
|
||||||
$sessionApplication = new SessionApplication($mysqlSettings, $cryptographyService);
|
$sessionApplication = new SessionApplication($mysqlSettings, $c['cryptographyService']);
|
||||||
return $sessionApplication;
|
return $sessionApplication;
|
||||||
};
|
};
|
||||||
|
@ -42,4 +42,7 @@ $app->get('/api/decrypt/password/{string}', function (Request $request, Response
|
|||||||
if ($cosa){
|
if ($cosa){
|
||||||
return "yea";
|
return "yea";
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
"nah";
|
||||||
|
}
|
||||||
});
|
});
|
Loading…
Reference in New Issue
Block a user