From d32c2ad1b916dc1dcb4703433d70f822d67f6f9d Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 22 Feb 2019 21:56:19 +0100 Subject: prepare account support --- index.pl | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'index.pl') 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'); -- cgit v1.2.3