Add login failed message instead of internal server error

This commit is contained in:
Citlali del Rey 2022-11-11 17:28:23 -08:00
parent e396723a89
commit 2c42321837
Signed by: nullobsi
GPG Key ID: 933A1F44222C2634
2 changed files with 13 additions and 1 deletions

View File

@ -33,8 +33,11 @@ sub auth($c) {
return $c->users->getOrMake($username);
})->then(sub ($res) {
$c->session->{uid} = $res;
$c->flash(message => "Logged in.");
$c->flash(msg => "Logged in.");
$c->redirect_to('/my');
})->catch(sub ($err) {
$c->flash(msg => "Login failed.");
$c->redirect_to('/login');
});
}

View File

@ -1,6 +1,15 @@
% layout "default";
% title "Login";
<h1>Login</h1>
% if (my $msg = flash 'msg') {
<p>
<b>
%= $msg
</b>
</p>
% }
%= form_for auth => (method => 'POST') => begin
<p>
%= label_for username => 'Username'