[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

@@ -0,0 +1,43 @@
<?php
namespace App\Application;
class SessionApplication{
// The to be connection
private $pdo = '';
function __construct($mysqlSettings, $cryptographyService){
// Services
$this->cryptographyService = $cryptographyService;
// The database parameters
$this->host = $mysqlSettings['host'];
$this->database = $mysqlSettings['database'];
$this->user = $mysqlSettings['user'];
$this->password = $mysqlSettings['password'];
$this->charset = $mysqlSettings['charset'];
$this->pdoConnectionOptions = $mysqlSettings['pdoConnectionOptions'];
// Generic error messages
$this->databaseConnectionErrorMessage = $mysqlSettings['databaseConnectionErrorMessage'];
$this->databaseSelectQueryErrorMessage = $mysqlSettings['databaseSelectQueryErrorMessage'];
$this->databaseInsertQueryErrorMessage = $mysqlSettings['databaseInsertQueryErrorMessage'];
// Initiate the connection
$dsn = "mysql:host=$this->host;dbname=$this->database;charset=$this->charset";
try {
$this->pdo = new PDO($dsn, $this->user, $this->password, $this->pdoConnectionOptions);
} catch (Exception $e) {
error_log($e->getMessage());
exit($this->databaseConnectionErrorMessage);
}
}
function newSession($userName, $password){
$real = 'slothness';
if($this->cryptographyService->decryptPassword($real, $password)){
}
}
}
?>