You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
975 B
29 lines
975 B
<?php
|
|
|
|
namespace App\Controller;
|
|
|
|
use App\Connexion;
|
|
use App\Gateway\AccountGateway;
|
|
use App\Http\HttpResponse;
|
|
use App\Model\AuthModel;
|
|
use App\Session\MutableSessionHandle;
|
|
|
|
class VisitorController {
|
|
final public function register(MutableSessionHandle $session): HttpResponse {
|
|
$model = new AuthModel(new AccountGateway(new Connexion(get_database())));
|
|
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
|
return (new Sub\AuthController($model))->displayRegister();
|
|
}
|
|
return (new Sub\AuthController($model))->confirmRegister($_POST, $session);
|
|
}
|
|
|
|
final public function login(MutableSessionHandle $session): HttpResponse {
|
|
$model = new AuthModel(new AccountGateway(new Connexion(get_database())));
|
|
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
|
return (new Sub\AuthController($model))->displayLogin();
|
|
}
|
|
return (new Sub\AuthController($model))->confirmLogin($_POST, $session);
|
|
}
|
|
|
|
}
|