Add success page.

This commit is contained in:
Dave Smith-Hayes 2024-05-23 22:39:38 -04:00
parent e2a3c95f99
commit f3f36b333c
6 changed files with 57 additions and 4 deletions

View File

@ -24,6 +24,13 @@ class Bootstrap
// set all configuration details // set all configuration details
$config->merge([
'site' => [
'name' => "Slovocast",
'description' => "A no-bullshit podcast hosting platform."
],
]);
return $config; return $config;
} }
@ -39,8 +46,9 @@ class Bootstrap
$config = self::initConfig(); $config = self::initConfig();
$containerBuilder->addDefinitions([ $containerBuilder->addDefinitions([
'conifg' => $config, 'config' => $config,
// more DI stuff // more DI stuff
]); ]);
return $containerBuilder->build(); return $containerBuilder->build();
@ -66,6 +74,10 @@ class Bootstrap
*/ */
protected static function establishMiddleware(App $app): void protected static function establishMiddleware(App $app): void
{ {
/**
* @var Configuration
*/
$config = $app->get('config');
$app->addErrorMiddleware(true, true, true); $app->addErrorMiddleware(true, true, true);
// Twig // Twig
@ -73,8 +85,10 @@ class Bootstrap
$templateCache = false; $templateCache = false;
$twig = Twig::create($templatePath, [ 'cache' => $templateCache ]); $twig = Twig::create($templatePath, [ 'cache' => $templateCache ]);
// Add the global variables // Add the global variables
$twig->getEnvironment()->addGlobal('site_name', "Slovocast"); $twig->getEnvironment()
$twig->getEnvironment()->addGlobal('site_description', "A no-bullshit podcast hosting service"); ->addGlobal('site_name', $config->get('site.name'));
$twig->getEnvironment()
->addGlobal('site_description', $config->get('site.description'));
$app->add(TwigMiddleware::create($app, $twig)); $app->add(TwigMiddleware::create($app, $twig));
} }

View File

@ -9,6 +9,8 @@ class RegisterUserAction extends Controller
{ {
public function respond(): Response public function respond(): Response
{ {
return $this->respond('users/register/success.twig'); // get user Data
return $this->render('user/success.twig');
} }
} }

View File

@ -93,6 +93,34 @@ class UserRepository implements UserRepositoryInterface
public function update(User $user): bool public function update(User $user): bool
{ {
$connection = $this->database->getConnection();
$query = "UPDATE users
SET email = :email,
name = :name,
password = :password
WHERE id = :id";
$statement = $connection->prepare($query);
return $statement->execute([
'email' => $user->getEmail(),
'name' => $user->getName(),
'password' => $this->userAuth->hash($user->getPassword()),
'id' => $user->getId()
]);
}
/**
* @param string $email
* @param string $password
* @return bool
*/
public function verifyPassword(string $email, string $password): bool
{
try {
$user = $this->getFromEmail($email);
return $this->authUser->verify($password, $user->getPassword());
} catch (\Exception $e) {
return false;
}
} }
} }

View File

@ -10,4 +10,5 @@ interface UserRepositoryInterface
public function getFromEmail(string $email): User; public function getFromEmail(string $email): User;
public function save(User $user): bool; public function save(User $user): bool;
public function update(User $user): bool; public function update(User $user): bool;
public function verifyPassword(string $email, string $password): bool;
} }

View File

@ -2,6 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<title>{% block page_title %}{% endblock %}</title> <title>{% block page_title %}{% endblock %}</title>
<meta name="description" value="{{ site_description }}">
</head> </head>
<body> <body>
<div class="container"> <div class="container">

View File

@ -0,0 +1,7 @@
{% extends 'layouts/skeleton.twig' %}
{% block content %}
<div>
<p>Successfully registered {{ email }}.</p>
</div>
{% endblock %}