Add timestamps to teh user since its also an entity, and test the login. Add a redirect helper for the responses.
This commit is contained in:
parent
aab1138163
commit
38cdd1bfb2
@ -19,6 +19,7 @@ final class AddTimeStampsToUsers extends AbstractMigration
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
|
||||
$table = $this->table("users")->addTimestamps();
|
||||
$table->update();
|
||||
}
|
||||
}
|
||||
|
@ -58,6 +58,19 @@ abstract class Controller
|
||||
->withHeader('Content-Type', 'text/html');
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect helper for sending the client elsewhere.
|
||||
*
|
||||
* @param string $route The route to redirect doe
|
||||
* @param int $code Default `301`, the code to respond with
|
||||
*/
|
||||
public function redirect(string $route, int $code = 301): Response
|
||||
{
|
||||
return $this->response
|
||||
->withHeader('Location', $route)
|
||||
->withStatus($code);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $html The raw Twig HTML to render
|
||||
* @param array $data The data to injext into the HTML
|
||||
|
@ -35,6 +35,6 @@ class LoginUserAction extends Controller
|
||||
|
||||
// start the session
|
||||
$this->session->set('user', [ 'id' => $user->getId(), 'authenticated' => true ]);
|
||||
return $this->render('dashboard.twig', [ 'logged_in' => true ]);
|
||||
return $this->redirect('/dashboard', 302);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user