mirror of
https://github.com/derf/travelynx
synced 2024-12-04 02:09:09 +00:00
prepare account support
This commit is contained in:
parent
5bc5f63868
commit
d32c2ad1b9
3 changed files with 88 additions and 0 deletions
32
index.pl
32
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');
|
||||
|
|
18
templates/login.html.ep
Normal file
18
templates/login.html.ep
Normal file
|
@ -0,0 +1,18 @@
|
|||
<div class="row">
|
||||
<form class="col s12">
|
||||
<div class="row">
|
||||
<div class="input-field col s12">
|
||||
<i class="material-icons prefix">account_circle</i>
|
||||
<input id="user" type="text" class="validate">
|
||||
<label for="user">User</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="input-field col s12">
|
||||
<i class="material-icons prefix">lock</i>
|
||||
<input id="password" type="password" class="validate">
|
||||
<label for="password">Password</label>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
38
templates/register.html.ep
Normal file
38
templates/register.html.ep
Normal file
|
@ -0,0 +1,38 @@
|
|||
<div class="row">
|
||||
%= form_for '/x/register' => (class => 'col s12', method => 'POST') => begin
|
||||
<div class="row">
|
||||
<div class="input-field col l6 m12 s12">
|
||||
<i class="material-icons prefix">account_circle</i>
|
||||
<input id="account" type="text" class="validate">
|
||||
<label for="account">Name</label>
|
||||
</div>
|
||||
<div class="input-field col l6 m12 s12">
|
||||
<i class="material-icons prefix">email</i>
|
||||
<input id="email" type="email" class="validate">
|
||||
<label for="email">Mail-Adresse</label>
|
||||
</div>
|
||||
<div class="input-field col l6 m12 s12">
|
||||
<i class="material-icons prefix">lock</i>
|
||||
<input id="password" type="password" class="validate">
|
||||
<label for="password">Passwort</label>
|
||||
</div>
|
||||
<div class="input-field col l6 m12 s12">
|
||||
<i class="material-icons prefix">lock</i>
|
||||
<input id="password2" type="password" class="validate">
|
||||
<label for="password2">Passwort wiederholen</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col s3 m3 l3">
|
||||
</div>
|
||||
<div class="col s6 m6 l6 center-align">
|
||||
<button class="btn waves-effect waves-light" type="submit" name="action" value="register">
|
||||
Registrieren
|
||||
<i class="material-icons right">send</i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="col s3 m3 l3">
|
||||
</div>
|
||||
</div>
|
||||
%= end
|
||||
</div>
|
Loading…
Reference in a new issue