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