StackTrace
+ Authentication
+
Session
Session::Store::DBIC
Session::State::Cookie
/;
-our $VERSION = '0.01';
+our $VERSION = '0.02';
my %LangsToUse = (
'de' => 'deutsch',
# local deployment.
__PACKAGE__->config(
+ 'authentication' => {
+ 'default_realm' => 'users',
+ 'realms' => {
+ 'users' => {
+ 'credential' => {
+ 'class' => 'Password',
+ 'password_field' => 'password',
+ 'password_type' => 'salted_hash',
+ 'password_salt_len' => 8,
+ },
+ 'store' => {
+ 'class' => 'DBIx::Class',
+ 'user_class' => 'Users',
+ 'id_field' => 'user_id',
+ },
+ },
+ },
+ },
'name' => 'FrBr::Books',
'session' => {
'dbic_class' => 'Schema::Session',
#$c->stash->{'lang_to_use'} = $lang;
#$c->log->debug( $K . "Neue Sprache: '" . $lang . "' (" . $LangsToUseInDates{$lang} . ")." ) if $c->stash->{'debug_level'} >= 2;
+ # Login-abhaengige Dinge
+
$c->stash->{'login_action'} = 'login';
+ if ( ( $c->controller eq $c->controller('Login') ) or ( $c->controller eq $c->controller('Logout') ) ) {
+ $c->stash->{'login_action'} = 'none';
+ }
+ elsif ( $c->user_exists ) {
+
+ my $user_info = $c->user();
+ #$c->log->debug( get_output_string( $K, "Aktueller Nutzer: ", $user_info ) ) if $c->config->{'debug_level'} >= 4;
+ my $uid = $user_info->user_id;
+ my $user_name = $user_info->login;
+ if ( $user_info->nachname ) {
+ $user_name = $user_info->nachname;
+ $user_name = $user_info->vorname . " " . $user_name if $user_info->vorname;
+ }
+ $c->stash->{'current_user'} = $user_name;
+ $c->stash->{'current_user_id'} = $user_info->user_id;
+ $c->stash->{'login_action'} = 'logout';
+ $c->stash->{'current_user_is_manager'} = 0;
+ $c->stash->{'current_user_is_human_resources'} = 0;
+ $c->stash->{'current_user_deps'} = {};
+ $c->session->{'current_user_name'} = $user_name;
+ $c->session->{'last_login_name'} = $user_info->login();
+
+ #set_last_activity_time($c);
+
+ if ( $c->stash->{'debug_level'} >= 2 ) {
+ $c->log->debug( $K
+ . "Aktuelle Nutzerinformationen:\n"
+ . " Name: '" . $c->stash->{'current_user'} . "'\n"
+ . " Nutzer-Id: " . $c->stash->{'current_user_id'} . "\n"
+ . " Ist Manager: " . ( $c->stash->{'current_user_is_manager'} ? 'Ja' : 'Nein' ) . "\n"
+ . " Ist Personaler: " . ( $c->stash->{'current_user_is_human_resources'} ? 'Ja' : 'Nein' ) . "\n"
+ . " Abteilungen: " . get_output_string( $c->stash->{'current_user_deps'} ) );
+ } ## end if ( $c->stash->{'debug_level'} >= 2 )
+
+ } ## end elsif ( $c->user_exists )
+
+ $c->stash->{'last_login_name'} = $c->session->{'last_login_name'};
+
$c->log->debug( $K . "Aktuelle Script-URL: '" . $c->stash->{'self_url'} . "'." ) if $c->stash->{'debug_level'} >= 2;
# Listenlaenge festlegen
} ## end sub auto :
+#-------------------------------------------------------
+
+sub not_allowed : Local {
+
+ my ( $self, $c ) = @_;
+ my $K = ( caller(0) )[3] . "(): ";
+
+ $c->stash->{'template'} = 'not_allowed.tt2';
+
+}
=head1 NAME
$c->log->debug( $K . "aufgerufen." ) if $c->stash->{'debug_level'} > 2;
+ unless ( $c->user_exists() ) {
+ $c->detach('/not_allowed');
+ return;
+ }
+
$c->stash->{'menu_path'} = [] unless $c->stash->{'menu_path'};
push @{ $c->stash->{'menu_path'} }, {
'path' => $c->web_path("/autor/new"),
$c->log->debug( $K . "aufgerufen." ) if $c->stash->{'debug_level'} > 2;
+ unless ( $c->user_exists() ) {
+ $c->detach('/not_allowed');
+ return;
+ }
+
$c->stash->{'menu_path'} = [] unless $c->stash->{'menu_path'};
$self->add_booklist_menu($c) if $c->session->{'from_book_list'};
push @{ $c->stash->{'menu_path'} }, {
$c->log->debug( $K . "aufgerufen." ) if $c->stash->{'debug_level'} > 2;
+ unless ( $c->user_exists() ) {
+ $c->detach('/not_allowed');
+ return;
+ }
+
$c->stash->{'menu_path'} = [] unless $c->stash->{'menu_path'};
$self->add_booklist_menu($c) if $c->session->{'from_book_list'};
push @{ $c->stash->{'menu_path'} }, {
$c->log->debug( $K . "aufgerufen." ) if $c->stash->{'debug_level'} > 2;
+ unless ( $c->user_exists() ) {
+ $c->detach('/not_allowed');
+ return;
+ }
+
$c->stash->{'menu_path'} = [] unless $c->stash->{'menu_path'};
$self->add_booklist_menu($c) if $c->session->{'from_book_list'};
push @{ $c->stash->{'menu_path'} }, {
$c->log->debug( $K . "aufgerufen." ) if $c->stash->{'debug_level'} > 2;
+ unless ( $c->user_exists() ) {
+ $c->detach('/not_allowed');
+ return;
+ }
+
$c->stash->{'menu_path'} = [] unless $c->stash->{'menu_path'};
push @{ $c->stash->{'menu_path'} }, {
'path' => $c->web_path("/kategorie/new"),
=cut
sub index : Private {
- my ( $self, $c ) = @_;
- $c->stash->{'template'} = 'not_implemented.tt2';
+ my ( $self, $c ) = @_;
push @{ $c->stash->{'menu_path'} }, {
'path' => $c->web_path("/login"),
'name' => "Anmeldung"
};
+ $c->stash->{'site_title'} = "Anmeldung an Franks Büchersammlung";
+
+ $c->stash->{'cssfiles'} = [] unless $c->stash->{'cssfiles'};
+ push @{ $c->stash->{'cssfiles'} }, 'login.css';
+
+ my $username = $c->request->params->{'username'};
+ my $password = $c->request->params->{'password'};
+
+ # If the username and password values were found in form
+ if ( $username && $password ) {
+
+ # Attempt to log the user in
+ my $rs = $c->model('Schema::Users')->search({ 'login' => $username, 'deleted' => 'n', 'enabled' => 'y' });
+ if ($c->authenticate({ 'password' => $password, 'dbix_class' => { resultset => $rs } })) {
+ $c->response->redirect( $c->web_path('/') );
+ return 1;
+ } ## end if ( $c->login( $username, $password ) )
+ else {
+ # Set an error message
+ $c->stash->{'error_msg'} = "Falscher Nutzername oder Paßwort.";
+ }
+ } ## end if ( $username && $password )
+
+ # If either of above don't work out, send to the login page
+ $c->stash->{'template'} = 'login.tt2';
+
}
--- /dev/null
+package FrBr::Books::Controller::Logout;
+
+# $Id$
+# $URL$
+
+use strict;
+use warnings;
+use base 'Catalyst::Controller';
+use FrBr::Common;
+
+=head1 NAME
+
+FrBr::Books::Controller::Logout - Catalyst Controller zum Abmelden
+
+=head1 DESCRIPTION
+
+Catalyst Controller.
+
+=head1 METHODS
+
+=cut
+
+
+=head2 index
+
+=cut
+
+sub index : Private {
+
+ my ( $self, $c ) = @_;
+ my $K = ( caller(0) )[3] . "(): ";
+
+ if ( $c->user_exists ) {
+ # Clear the user's state
+ $c->logout;
+ }
+
+ # Ueberfluessige Sitzungsdaten weg ...
+ my @Keys = qw(
+ list_length
+ );
+ for my $key (@Keys) {
+ delete $c->session->{$key} if $c->session->{$key};
+ }
+
+ $c->stash->{'login_action'} = 'none';
+
+ # Send the user to the starting point
+ $c->response->redirect( $c->web_path('/') );
+
+ #$c->stash->{'site_title'} = $c->localize("Logout");
+ $c->stash->{'site_title'} = "Abmelden";
+
+}
+
+
+=head1 AUTHOR
+
+Frank Brehm
+
+=head1 LICENSE
+
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+1;
+
+__END__
+
+# vim: noai : ts=4 fenc=utf-8 filetype=perl expandtab :
$c->log->debug( $K . "aufgerufen." ) if $c->stash->{'debug_level'} > 2;
+ unless ( $c->user_exists() ) {
+ $c->detach('/not_allowed');
+ return;
+ }
+
$c->stash->{'menu_path'} = [] unless $c->stash->{'menu_path'};
push @{ $c->stash->{'menu_path'} }, {
'path' => $c->web_path("/ort/new"),
$c->log->debug( $K . "aufgerufen." ) if $c->stash->{'debug_level'} > 2;
+ unless ( $c->user_exists() ) {
+ $c->detach('/not_allowed');
+ return;
+ }
+
$c->stash->{'menu_path'} = [] unless $c->stash->{'menu_path'};
push @{ $c->stash->{'menu_path'} }, {
'path' => $c->web_path("/serie/new"),
$c->log->debug( $K . "aufgerufen." ) if $c->stash->{'debug_level'} > 2;
+ unless ( $c->user_exists() ) {
+ $c->detach('/not_allowed');
+ return;
+ }
+
$c->stash->{'menu_path'} = [] unless $c->stash->{'menu_path'};
push @{ $c->stash->{'menu_path'} }, {
'path' => $c->web_path("/verlag/new"),
<td colspan="2" class="empty">
</td>
</tr>
- <tr>
+ [% IF Catalyst.user_exists %]<tr>
<td class="button">
</td>
<td class="item">
<tr>
<td colspan="2" class="empty">
</td>
- </tr>
+ </tr>[% END %]
<tr>
<td class="button">
</td>
-[%#
+<!-- [%#
** Template fuer Autorenliste
**
** vim: noai : ts=4 fenc=utf-8 filetype=html expandtab :
** $URL$
** -%]
+ Autorenliste
+
+-->
+
[% META title = 'Autorenliste' -%]
<div class="center">
<table class="wrapper" cellspacing="0">
<tr><th>Liste der Bücher</th> </tr>
-<tr><td class="action"><a href="[% path('/autor/new') %]">Neuer Autor ...</a></td></tr>
+[% IF Catalyst.user_exists %]<tr><td class="action"><a href="[% path('/autor/new') %]">Neuer Autor ...</a></td></tr>[% END %]
<tr><td><table class="autorliste">
<tr>
<th>Name des Autors</th>
<th>zusätzliche Angaben</th>
<th>Bücher</th>
<th></th>
- <th></th>
- <th></th>
+ [% IF Catalyst.user_exists %]<th></th>
+ <th></th>[% END %]
</tr>
[% rowstyle = 'even' %][%- FOREACH author IN authors -%][% author_id = author.id %]
<tr>
<li>[% book.title %][% IF book.untertitel %] ([% book.untertitel %])[% END %]</li>[% END %][% ELSE %]<li><i>keine</i></li>[% END %]
</ul></td>
<td class="button [% rowstyle %]"><a href="[% path('/autor/view') %]?view_autor_id=[% author.id %]">Ansehen</a></td>
- <td class="button [% rowstyle %]"><a href="[% path('/autor/edit') %]?edit_autor_id=[% author.id %]">Ändern</a></td>
- <td class="button [% rowstyle %]">[% IF author.books and author.books.size > 0 %]Löschen[% ELSE %]<a href="[% path('/autor/delete') %]?delete_autor_id=[% author.id %]">Löschen</a>[% END %]</td>
+ [% IF Catalyst.user_exists %]<td class="button [% rowstyle %]"><a href="[% path('/autor/edit') %]?edit_autor_id=[% author.id %]">Ändern</a></td>
+ <td class="button [% rowstyle %]">[% IF author.books and author.books.size > 0 %]Löschen[% ELSE %]<a href="[% path('/autor/delete') %]?delete_autor_id=[% author.id %]">Löschen</a>[% END %]</td>[% END %]
</tr>
[% IF rowstyle == 'even' %][% rowstyle = 'odd'%][% ELSE %][% rowstyle = 'even' %][% END %][% END -%]
</table></td></tr></table>
-[%#
+<!-- [%#
- message.tt2 - Universal-Template
+ books/index.tt2.tt2 - Template für Bücher-Menü
vim: noai : ts=4 fenc=utf-8 filetype=html expandtab :
$URL$
-%]
+
+ Bücher-Menü
+
+-->
<div style="text-align: center">
<table class="menu" cellspacing="0">
<tr>
</tr><tr>
<td colspan="2" class="empty">
</td>
- </tr><tr>
+ [% IF Catalyst.user_exists %]</tr><tr>
<td class="button">
</td>
<td class="item">
<a href="[% path('/books/new') %]">Neues Buch</a></td>
</tr><tr>
<td colspan="2" class="empty">
- </td>
+ </td>[% END %]
</tr><tr>
<td class="button">
</td>
-[%#
+<!-- [%#
** Template fuer Buecherliste
**
** vim: noai : ts=4 fenc=utf-8 filetype=html expandtab :
** $URL$
** -%]
-[% META title = 'Bücherliste' -%]
+ Bücherliste
+
+-->
+
+[% tab_colspan = 6 %][% IF Catalyst.user_exists %][% tab_colspan = 8 %][% END %][% META title = 'Bücherliste' -%]
[% BLOCK navrow %]
<tr>
- <td class="nav" colspan="8"><table cellspacing="0" class="nav" width="100%">
+ <td class="nav" colspan="[% tab_colspan %]"><table cellspacing="0" class="nav" width="100%">
<tr>
<td width="33%" style="text-align: left;"><b>[% IF book_liste_page.cur != 1 %]<a href="[% self_url %]?page=1" title="Erste Seite"><<</a>[% ELSE %]<<[% END %] [% IF book_liste_page.cur != book_liste_page.prev %]<a href="[% self_url %]?page=[% book_liste_page.prev %]" title="Vorherige Seite"><</a>[% ELSE %]<[% END %]</b></td>
<td width="33%" style="text-align: center;">Buch [% book_liste_page.book_from %] bis [% book_liste_page.book_to %] von [% book_liste_page.books %]</td>
<table class="wrapper" cellspacing="0">
<tr><th>Liste der Bücher</th> </tr>
-<tr><td class="action"><a href="[% path('/books/new') %]">Neues Buch ...</a></td></tr>
+[% IF Catalyst.user_exists %]<tr><td class="action"><a href="[% path('/books/new') %]">Neues Buch ...</a></td></tr>[% END %]
<tr><td><table class="buchliste" cellspacing="0">
<tr>
<th>Autor (-en)</th>
<th>Verlag</th>
<th>Aufbewahrungsort</th>
<th></th>
- <th></th>
- <th></th>
+ [% IF Catalyst.user_exists %]<th></th>
+ <th></th>[% END %]
</tr>[% PROCESS navrow %]
[% rowstyle = 'even' %][%- FOREACH book IN books -%][% buch_id = book.id %]
<tr>
<td class="[% rowstyle %]">[% book.verlagsname_short %]</td>
<td class="[% rowstyle %]">[% IF book.orts_id %][% book.ortsname %][% ELSE %]unbekannt[% END %]</td>
<td class="[% rowstyle %] button"><a href="[% path('/books/view') %]?view_book_id=[% book.id %]">Ansehen</a></td>
- <td class="[% rowstyle %] button"><a href="[% path('/books/edit') %]?edit_book_id=[% book.id %]">Ändern</a></td>
- <td class="[% rowstyle %] button"><a href="[% path('/books/delete') %]?delete_book_id=[% book.id %]">Löschen</a></td>
+ [% IF Catalyst.user_exists %]<td class="[% rowstyle %] button"><a href="[% path('/books/edit') %]?edit_book_id=[% book.id %]">Ändern</a></td>
+ <td class="[% rowstyle %] button"><a href="[% path('/books/delete') %]?delete_book_id=[% book.id %]">Löschen</a></td>[% END %]
</tr>
[% IF rowstyle == 'even' %][% rowstyle = 'odd'%][% ELSE %][% rowstyle = 'even' %][% END %][% END -%]
[% PROCESS navrow %]</table></td></tr></table>
<td colspan="2" class="empty">
</td>
</tr>
- <tr>
+ [% IF Catalyst.user_exists %]<tr>
<td class="button">
</td>
<td class="item">
<tr>
<td colspan="2" class="empty">
</td>
- </tr>
+ </tr>[% END %]
<tr>
<td class="button">
</td>
--- /dev/null
+/* [%#
+ # Template fuer Stylesheets Login-Formular
+ #
+ # $Id$
+ # $URL$
+ #
+-%]
+
+Stylesheets Autoren */
+
+DIV.center {
+ margin: auto;
+ text-align: center;
+ width: auto;
+}
+
+TABLE.wrapper {
+ border-spacing: 0;
+ margin: auto;
+}
+
+TABLE.wrapper TH {
+ text-align: center;
+ font-size: 1.2em;
+}
+
+TABLE.wrapper TD {
+ text-align: left;
+}
+
+TABLE.wrapper TD.action {
+ font-weight: bolder;
+ padding-top: 1em;
+ padding-bottom: 1em;
+}
+
+TABLE.login {
+ border-width: 2px;
+ border-style: solid;
+ border-top-color: [% site.col.tab_rahmen_hell %];
+ border-left-color: [% site.col.tab_rahmen_hell %];
+ border-right-color: [% site.col.tab_rahmen_dkl %];
+ border-bottom-color: [% site.col.tab_rahmen_dkl %];
+ border-collapse: separate;
+ border-spacing: 0;
+ margin: auto;
+}
+
+TABLE.login TH {
+ vertical-align: top;
+ text-align: left;
+ font-size: 1em;
+ padding: 2px;
+ border-width: 1px;
+ border-style: solid;
+ border-top-color: [% site.col.tab_rahmen_dkl %];
+ border-left-color: [% site.col.tab_rahmen_dkl %];
+ border-right-color: [% site.col.tab_rahmen_hell %];
+ border-bottom-color: [% site.col.tab_rahmen_hell %];
+ background-color: [% site.col.list_head %];
+}
+
+TABLE.login TD {
+ vertical-align: top;
+ font-size: 1em;
+ padding: 2px;
+ border-width: 1px;
+ border-style: solid;
+ border-top-color: [% site.col.tab_rahmen_dkl %];
+ border-left-color: [% site.col.tab_rahmen_dkl %];
+ border-right-color: [% site.col.tab_rahmen_hell %];
+ border-bottom-color: [% site.col.tab_rahmen_hell %];
+ background-color: [% site.col.list_row_bold %];
+}
+
+TABLE.login TD.empty {
+ height: 3px;
+}
+
+TABLE.login TH.button {
+ font-weight: bolder;
+ text-align: center;
+ padding-left: 1em;
+ padding-right: 1em;
+}
+
+TABLE.login TH.button INPUT {
+ font-weight: bolder;
+ font-size: 1.2em;
+ padding-left: 2em;
+ padding-right: 2em;
+}
+
--- /dev/null
+<!-- [%#
+ Template zur Darstellung des Login-Formulars
+
+ vim: noai : ts=4 fenc=utf-8 filetype=html expandtab :
+
+ $Id$
+ $URL$
+
+-%]
+
+Login form -->
+
+[%- META title = 'Anmeldung an Franks Büchersammlung' -%]
+<div class="center">
+
+<form method="post" action="[% path('/login') %]">
+ <table class="login" cellspacing="0">
+ <tr>
+ <th colspan="2" class="title">Anmeldung am System</th>
+ </tr><tr>
+ <td colspan="2" class="empty"></td>
+ </tr><tr>
+ <th>Nutzername:</th>
+ <td><input type="text" name="username" size="40" [% IF last_login_name %]value="[% last_login_name %]" [% END %]/></td>
+ </tr><tr>
+ <th>Paßwort:</th>
+ <td><input type="password" name="password" size="40" /></td>
+ </tr><tr>
+ <td colspan="2" class="empty"></td>
+ </tr><tr>
+ <th colspan="2" class="button"><input type="submit" name="submit" value="Anmelden" /></th>
+ </tr>
+ </table>
+</form>
+[%- IF error_msg %]
+<div class="error">
+<span class="bold">Fehler:</span> [% error_msg %]
+</div>
+[% END %]
+<div class="back">
+<h2><a href="[% path('/') %]">Zurück</a></h2>
+</div>
+
+</div>
--- /dev/null
+<!-- [%#
+
+ Template zur Darstellung einer nicht erlaubten Aktion
+
+ vim: noai : ts=4 fenc=utf-8 filetype=html expandtab :
+
+ $Id$
+ $URL$
+
+%]
+
+Das ist hier nicht erlaubt!!!
+
+-->
+
+<h2>Sie sind nicht angemeldet.</h2>
+<h3>Das gewünschte Feature ist Ihnen deshalb nicht zugänglich.</h3>
+<br />
+<br />
+<h1 style="text-align: center;"><a href="[% path('/') %]">OK</a></h1>
+
<td colspan="2" class="empty">
</td>
</tr>
- <tr>
+ [% IF Catalyst.user_exists %]<tr>
<td class="button">
</td>
<td class="item">
<tr>
<td colspan="2" class="empty">
</td>
- </tr>
+ </tr>[% END %]
<tr>
<td class="button">
</td>
<td colspan="2" class="empty">
</td>
</tr>
- <tr>
+ [% IF Catalyst.user_exists %]<tr>
<td class="button">
</td>
<td class="item">
<tr>
<td colspan="2" class="empty">
</td>
- </tr>
+ </tr>[% END %]
<tr>
<td class="button">
</td>
<td colspan="2" class="empty">
</td>
</tr>
- <tr>
+ [% IF Catalyst.user_exists %]<tr>
<td class="button">
</td>
<td class="item">
<tr>
<td colspan="2" class="empty">
</td>
- </tr>
+ </tr>[% END %]
<tr>
<td class="button">
</td>