3
0

ajout de la possibilité de s'inscrire

This commit is contained in:
Philippe Pittoli 2014-01-22 23:04:54 +01:00
parent 9c3765fdb2
commit f7661b1449
3 changed files with 72 additions and 3 deletions

View File

@ -82,9 +82,9 @@ get '/home' => sub {
my $cf = session('creationFailure');
my $dn = session('domainName');
session 'creationSuccess' => '';
session 'creationFailure' => '';
session 'domainName' => '';
session creationSuccess => '';
session creationFailure => '';
session domainName => '';
template home => {
login => session('login')
@ -245,6 +245,44 @@ prefix '/user' => sub {
redirect '/';
};
post '/add/' => sub {
if ( param('login') && param('password') )
{
my $app = initco();
$app->register_user(param('login'), param('password'));
session login => param('login');
session password => param('password');
redirect '/home';
}
else {
session errmsg => q/login ou password non renseignés/;
redirect '/user/subscribe';
}
};
get '/subscribe' => sub {
if( defined session('login') )
{
redirect '/home';
}
else {
my $errmsg = session 'errmsg' ;
session errmsg => '';
template subscribe => {
errmsg => $errmsg
};
}
};
get '/del/:user' => sub {
my $app = initco();

View File

@ -57,4 +57,6 @@
</ul>
<p>En résumé : cherchez votre nom de domaine, réservez-le, on s'occupe du reste ! </p>
<h3><a href="/user/subscribe" >S'enregistrer</a></h3>
</div>

29
www/views/subscribe.tt Normal file
View File

@ -0,0 +1,29 @@
<div id="sidebar">
Welcome <% login %> !
<br />
<a href="/user/logout">Déconnexion</a>
<br />
<% IF admin == 1 %>
<a href='/admin'>Page d'administration</a>
<br />
<% END %>
<a href='/'>Accueil</a>
</div>
<div id="page">
<% errmsg %> <br />
<form action='/user/add/' method="post" >
<label for='login'>login : </label>
<input type='text' name='login' id='login' />
<label for='password'>password : </label>
<input type='password' name='password' id='password' />
<input type='submit' name='submit'/>
</form>
</div>