diff --git a/index.pl b/index.pl index 4b5bc9bbd219587045e3b3f6797f310da25e1662..5a7e5982d09427f18b73db060683776c4249ac94 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'); diff --git a/templates/login.html.ep b/templates/login.html.ep new file mode 100644 index 0000000000000000000000000000000000000000..b9b79ebcdc994028f50ab7fe0a5155db2fbdc0c7 --- /dev/null +++ b/templates/login.html.ep @@ -0,0 +1,18 @@ +
+
+
+
+ account_circle + + +
+
+
+
+ lock + + +
+
+
+
diff --git a/templates/register.html.ep b/templates/register.html.ep new file mode 100644 index 0000000000000000000000000000000000000000..44313304bc4b0598bc792bf6adcf8507d57083ee --- /dev/null +++ b/templates/register.html.ep @@ -0,0 +1,38 @@ +
+ %= form_for '/x/register' => (class => 'col s12', method => 'POST') => begin +
+
+ account_circle + + +
+
+ email + + +
+
+ lock + + +
+
+ lock + + +
+
+
+
+
+
+ +
+
+
+
+ %= end +