Add some authorization to the infrastructure code.
This commit is contained in:
parent
54473bdf79
commit
0518a44d3f
@ -23,4 +23,9 @@ class DatabaseConnection implements DatabaseConnectionInterface
|
||||
{
|
||||
return $this->pdo;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
|
22
code/src/Infrastructure/User/BasicUserAuthorization.php
Normal file
22
code/src/Infrastructure/User/BasicUserAuthorization.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Slovocast\Infrastructure\User;
|
||||
|
||||
use Slovocast\Infrastructure\User\UserAuthorizationInterface;
|
||||
|
||||
/**
|
||||
* This empty class will essentially just check hashed passwords passed
|
||||
* into it using the default `password_` functions from PHP.
|
||||
*/
|
||||
class BasicUserAuthorization implements UserAuthorizationInterface
|
||||
{
|
||||
public function hash(string $password): string
|
||||
{
|
||||
return password_hash($password, PASSWORD_BCRYPT);
|
||||
}
|
||||
|
||||
public function verify(string $password, string $hash): bool
|
||||
{
|
||||
return password_verify($password, $hash);
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Slovocast\Infrastructure\User;
|
||||
|
||||
interface UserAuthorizationInterface
|
||||
{
|
||||
public function hash(string $password): string;
|
||||
public function verify(string $password, string $hash): bool;
|
||||
}
|
Loading…
Reference in New Issue
Block a user