diff options
author | dakkar <dakkar@luxion> | 2006-02-09 12:35:14 +0000 |
---|---|---|
committer | dakkar <dakkar@luxion> | 2006-02-09 12:35:14 +0000 |
commit | ce0dd6514a8b77da30d03542500847b9bbec6962 (patch) | |
tree | 5d8373820e620654b5ae6627dc92f9c4fb1af316 | |
parent | funge il modello... ca**o (diff) | |
download | IscrittiGroLUG-ce0dd6514a8b77da30d03542500847b9bbec6962.tar.gz IscrittiGroLUG-ce0dd6514a8b77da30d03542500847b9bbec6962.tar.bz2 IscrittiGroLUG-ce0dd6514a8b77da30d03542500847b9bbec6962.zip |
login e lista iscritti
git-svn-id: svn://luxion/repos/IscrittiGroLUG/trunk@171 fcb26f47-9200-0410-b104-b98ab5b095f3
-rw-r--r-- | GroLUG/grolug.yml | 4 | ||||
-rw-r--r-- | GroLUG/lib/GroLUG.pm | 21 | ||||
-rw-r--r-- | GroLUG/lib/GroLUG/C/Iscritti.pm | 58 | ||||
-rw-r--r-- | GroLUG/lib/GroLUG/M/DB/Iscritto.pm | 6 | ||||
-rw-r--r-- | GroLUG/logger.conf | 7 | ||||
-rw-r--r-- | GroLUG/root/src/lista-iscritti.tt2 | 6 | ||||
-rw-r--r-- | GroLUG/root/src/login.tt2 | 5 | ||||
-rw-r--r-- | GroLUG/usersfile | 1 |
8 files changed, 61 insertions, 47 deletions
diff --git a/GroLUG/grolug.yml b/GroLUG/grolug.yml index 1e1d18e..925c897 100644 --- a/GroLUG/grolug.yml +++ b/GroLUG/grolug.yml @@ -3,4 +3,6 @@ name: GroLUG session: expires: 3600 dbi_dbh: 'GroLUG::M::DB' - dbi_table: 'sessions' + dbi_table: 'sessioni' +authentication: + htpasswd: usersfile diff --git a/GroLUG/lib/GroLUG.pm b/GroLUG/lib/GroLUG.pm index 404fde1..267231f 100644 --- a/GroLUG/lib/GroLUG.pm +++ b/GroLUG/lib/GroLUG.pm @@ -1,19 +1,30 @@ package GroLUG; - use strict; use warnings; -use Catalyst qw/-Debug ConfigLoader Static::Simple DefaultEnd Session Session::Store::DBI Session::State::Cookie/; +use Catalyst qw{ + -Debug + ConfigLoader Static::Simple DefaultEnd + Session Session::Store::DBI Session::State::Cookie + Authentication Authentication::Store::Htpasswd Authentication::Credential::Password + Authorization::Roles + }; +use Catalyst::Log::Log4perl; our $VERSION = '0.01'; __PACKAGE__->setup; +#__PACKAGE__->log(Catalyst::Log::Log4perl->new(__PACKAGE__->path_to("logger.conf")->stringify)); -sub default : Private { +sub index : Private { my ( $self, $c ) = @_; - # Hello World - $c->response->body( $c->welcome_message ); + if ($c->user_exists) { + $c->res->redirect($c->uri_for('/iscritti')); + } + else { + $c->res->redirect($c->uri_for('/login')) + } } 1; diff --git a/GroLUG/lib/GroLUG/C/Iscritti.pm b/GroLUG/lib/GroLUG/C/Iscritti.pm index d79aea6..3afc852 100644 --- a/GroLUG/lib/GroLUG/C/Iscritti.pm +++ b/GroLUG/lib/GroLUG/C/Iscritti.pm @@ -4,46 +4,22 @@ use strict; use warnings; use base 'Catalyst::Controller'; -=head1 NAME - -GroLUG::C::Iscritti - Catalyst Controller - -=head1 SYNOPSIS - -See L<GroLUG> - -=head1 DESCRIPTION - -Catalyst Controller. - -=head1 METHODS - -=cut - -# -# Uncomment and modify this or add new actions to fit your needs -# -#=head2 default -# -#=cut -# -#sub default : Private { -# my ( $self, $c ) = @_; -# -# # Hello World -# $c->response->body('GroLUG::C::Iscritti is on Catalyst!'); -#} - - -=head1 AUTHOR - -A clever guy - -=head1 LICENSE - -This library is free software, you can redistribute it and/or modify -it under the same terms as Perl itself. - -=cut +sub login :Global { + my ( $self, $c ) = @_; + + if ($c->login) { + $c->res->redirect($c->uri_for('/iscritti')); + } + else { + $c->stash->{template}='login.tt2'; + } +} + +sub index :Private { + my ( $self, $c ) = @_; + + $c->stash->{iscritti}=GroLUG::M::DB->resultset('Iscritto')->search({attivo=>1}); + $c->stash->{template}='lista-iscritti.tt2'; +} 1; diff --git a/GroLUG/lib/GroLUG/M/DB/Iscritto.pm b/GroLUG/lib/GroLUG/M/DB/Iscritto.pm index 686b4b2..ca475ee 100644 --- a/GroLUG/lib/GroLUG/M/DB/Iscritto.pm +++ b/GroLUG/lib/GroLUG/M/DB/Iscritto.pm @@ -7,4 +7,10 @@ __PACKAGE__->add_columns(qw(id nome email attivo note)); __PACKAGE__->set_primary_key('id'); __PACKAGE__->has_many(pagamenti=>'GroLUG::M::DB::Pagamento','iscritto',{order_by => 'data_scadenza desc'}); +sub scadenza { + my ($self)=@_; + + return $self->pagamenti()->next()->data_scadenza(); +} + 1; diff --git a/GroLUG/logger.conf b/GroLUG/logger.conf new file mode 100644 index 0000000..f1d38de --- /dev/null +++ b/GroLUG/logger.conf @@ -0,0 +1,7 @@ +log4perl.logger.GroLUG = DEBUG, ConsoleAppender + +log4perl.appender.ConsoleAppender = Log::Log4perl::Appender::Screen +log4perl.appender.ConsoleAppender.stderr = 1 +log4perl.appender.ConsoleAppender.layout = Log::Log4perl::Layout::PatternLayout +log4perl.appender.ConsoleAppender.ConversionPattern =[%d] [catalyst] [%p] %m%n + diff --git a/GroLUG/root/src/lista-iscritti.tt2 b/GroLUG/root/src/lista-iscritti.tt2 new file mode 100644 index 0000000..2ade27a --- /dev/null +++ b/GroLUG/root/src/lista-iscritti.tt2 @@ -0,0 +1,6 @@ +<h1>Lista iscritti</h1> +<ol> +[% WHILE (iscr = iscritti.next()) %] +<li>[% iscr.nome %] - scade: [% iscr.scadenza %]</li> +[% END %] +</ol> diff --git a/GroLUG/root/src/login.tt2 b/GroLUG/root/src/login.tt2 new file mode 100644 index 0000000..69c2a46 --- /dev/null +++ b/GroLUG/root/src/login.tt2 @@ -0,0 +1,5 @@ +<form action="[% c.uri_for('/login') %]" method="post"> + <p><label for="user">Username:</label><input type="text" name="user" id="user" /></p> + <p><label for="password">Password:</label><input type="password" name="password" id="password" /></p> + <p><input type="submit" /></p> +</form> diff --git a/GroLUG/usersfile b/GroLUG/usersfile new file mode 100644 index 0000000..1f4f26e --- /dev/null +++ b/GroLUG/usersfile @@ -0,0 +1 @@ +dakkar:{SHA}qUqP5cyxm6YcTAhz05Hph5gvu9M=:admin |