🐛 sonarqube

pull/3/head
remrem 1 year ago
parent 3d3727ec61
commit 7c483c3338

@ -8,7 +8,7 @@ class DatabaseCon{
private string $login;
private string $password;
function __construct(){
public function __construct(){
if (getenv("SMDB_HOST") == null || getenv("SMDB_DATABASE") == null || getenv("SMDB_USER") == null || getenv("SMDB_PASSWORD") == null){
throw new PDOException("ENV variables not found");
}
@ -17,7 +17,7 @@ class DatabaseCon{
$this->password = getenv("SMDB_PASSWORD");
}
function connect(): int|Connection {
public function connect(): int|Connection {
try {
$connection = new Connection($this->dsn,$this->login,$this->password);
} catch (PDOException $e){

@ -1,9 +1,9 @@
<?php
declare(strict_types=1);
require "gateway/user_gateway.php";
require "gateway/file_gateway.php";
require "database_con.php";
require "token.php";
require_once "gateway/user_gateway.php";
require_once "gateway/file_gateway.php";
require_once "database_con.php";
require_once "token.php";
header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE");

@ -10,7 +10,7 @@ class Token {
// Need to be in a config file
private string $path_to_key="../sym_keyfile.key";
function __construct()
public function __construct()
{
#$file = fopen($this->path_to_key, 'r');
#$this->key = fread($file, filesize($this->path_to_key));
@ -18,7 +18,7 @@ class Token {
}
// Return json containing JWT with uuid and exp
function getNewJsonToken(string $uuid) :array {
public function getNewJsonToken(string $uuid) :array {
$payload = [
'uuid' => $uuid,
'exp' => strtotime("+2month", time())
@ -28,7 +28,7 @@ class Token {
}
// Verify the JWT authenticity
function verifyToken(string $jwt) :bool {
public function verifyToken(string $jwt) :bool {
try {
JWT::decode($jwt, new Key($this->key, 'HS256'));
} catch (Exception $e) {
@ -39,7 +39,7 @@ class Token {
// Get uuid from JWT
// Missing error handling on bad JWT
function getUuidFromToken(string $jwt) :string {
public function getUuidFromToken(string $jwt) :string {
$decoded = (array) JWT::decode($jwt, new Key($this->key, 'HS256'));
return $decoded['uuid'];
}

Loading…
Cancel
Save