diff options
author | Daniel Friesel <derf@finalrewind.org> | 2019-02-22 21:56:19 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2019-02-22 21:56:19 +0100 |
commit | d32c2ad1b916dc1dcb4703433d70f822d67f6f9d (patch) | |
tree | 376f242d716912bd9878654f73e846fee2555022 /index.pl | |
parent | 5bc5f638680a9faae2f1bc3309b0b0f998e6884d (diff) |
prepare account support
Diffstat (limited to 'index.pl')
-rwxr-xr-x | index.pl | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -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'); |