summaryrefslogtreecommitdiff
path: root/index.pl
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-02-22 21:56:19 +0100
committerDaniel Friesel <derf@finalrewind.org>2019-02-22 21:56:19 +0100
commitd32c2ad1b916dc1dcb4703433d70f822d67f6f9d (patch)
tree376f242d716912bd9878654f73e846fee2555022 /index.pl
parent5bc5f638680a9faae2f1bc3309b0b0f998e6884d (diff)
prepare account support
Diffstat (limited to 'index.pl')
-rwxr-xr-xindex.pl32
1 files changed, 32 insertions, 0 deletions
diff --git a/index.pl b/index.pl
index 4b5bc9b..5a7e598 100755
--- a/index.pl
+++ b/index.pl
@@ -1,6 +1,7 @@
#!/usr/bin/env perl
use Mojolicious::Lite;
+use Mojolicious::Plugin::Authentication;
use Cache::File;
use DateTime;
use DBI;
@@ -33,6 +34,27 @@ my %action_type = (
undo => 3,
);
+app->plugin(authentication => {
+ autoload_user => 1,
+ session_key => 'foodor',
+ load_user => sub {
+ my ($app, $uid) = @_;
+ if ($uid == 1) {
+ return {
+ name => 'derf',
+ };
+ }
+ return undef;
+ },
+ validate_user => sub {
+ my ($c, $username, $password, $extradata) = @_;
+ if ($username eq 'derf' and $password eq 'hallo') {
+ return 1;
+ }
+ return undef;
+ },
+});
+
app->defaults( layout => 'default' );
app->attr(
@@ -772,6 +794,16 @@ post '/x/geolocation' => sub {
};
+get '/x/login' => sub {
+ my ($self) = @_;
+ $self->render('login');
+};
+
+get '/x/register' => sub {
+ my ($self) = @_;
+ $self->render('register');
+};
+
get '/*station' => sub {
my ($self) = @_;
my $station = $self->stash('station');