Revision 8c7e4493
Von Moritz Bunkus vor fast 17 Jahren hinzugefügt
bin/mozilla/login.pl | ||
---|---|---|
28 | 28 |
####################################################################### |
29 | 29 |
|
30 | 30 |
use DBI; |
31 |
use SL::Auth; |
|
31 | 32 |
use SL::User; |
32 | 33 |
use SL::Form; |
33 | 34 |
|
34 | 35 |
require "bin/mozilla/common.pl"; |
35 | 36 |
|
37 |
# This is required because the am.pl in the root directory |
|
38 |
# is not scanned by locales.pl: |
|
39 |
# $form->parse_html_template('login/password_error') |
|
40 |
|
|
36 | 41 |
$form = new Form; |
37 | 42 |
|
43 |
if (! -f 'config/authentication.pl') { |
|
44 |
show_error('login/authentication_pl_missing'); |
|
45 |
} |
|
46 |
|
|
38 | 47 |
$locale = new Locale $language, "login"; |
39 | 48 |
|
49 |
our $auth = SL::Auth->new(); |
|
50 |
if (!$auth->session_tables_present()) { |
|
51 |
show_error('login/auth_db_unreachable'); |
|
52 |
} |
|
53 |
$auth->expire_sessions(); |
|
54 |
$auth->restore_session(); |
|
55 |
|
|
40 | 56 |
# customization |
41 | 57 |
if (-f "bin/mozilla/custom_$form->{script}") { |
42 | 58 |
eval { require "bin/mozilla/custom_$form->{script}"; }; |
... | ... | |
53 | 69 |
$form->{titlebar} = "Lx-Office " . $locale->text('Version') . " $form->{version}"; |
54 | 70 |
|
55 | 71 |
if ($form->{action}) { |
72 |
our %myconfig = $auth->read_user($form->{login}) if ($form->{login}); |
|
73 |
|
|
74 |
if (!$myconfig{login} || (SL::Auth::OK != $auth->authenticate($form->{login}, $form->{password}, 0))) { |
|
75 |
$form->{error_message} = $locale->text('Incorrect Password!'); |
|
76 |
login_screen(); |
|
77 |
exit; |
|
78 |
} |
|
79 |
|
|
80 |
$auth->set_session_value('login', $form->{login}, 'password', $form->{password}); |
|
81 |
$auth->create_or_refresh_session(); |
|
82 |
|
|
56 | 83 |
$form->{titlebar} .= " - $myconfig{name} - $myconfig{dbname}"; |
57 | 84 |
call_sub($locale->findsub($form->{action})); |
58 | 85 |
|
... | ... | |
87 | 114 |
exit; |
88 | 115 |
} |
89 | 116 |
|
90 |
$user = new User $memberfile, $form->{login};
|
|
117 |
$user = new User $form->{login}; |
|
91 | 118 |
|
92 | 119 |
# if we get an error back, bale out |
93 |
if (($result = $user->login(\%$form, $userspath)) <= -1) {
|
|
120 |
if (($result = $user->login($form)) <= -1) {
|
|
94 | 121 |
exit if $result == -2; |
95 | 122 |
login_screen($locale->text('Incorrect username or password!')); |
96 | 123 |
exit; |
... | ... | |
106 | 133 |
# made it this far, execute the menu |
107 | 134 |
$form->{callback} = build_std_url("script=menu${menu_script}.pl", 'action=display'); |
108 | 135 |
|
136 |
$auth->set_cookie_environment_variable(); |
|
137 |
|
|
109 | 138 |
$form->redirect(); |
110 | 139 |
|
111 | 140 |
$lxdebug->leave_sub(); |
... | ... | |
114 | 143 |
sub logout { |
115 | 144 |
$lxdebug->enter_sub(); |
116 | 145 |
|
117 |
unlink "$userspath/$form->{login}.conf";
|
|
146 |
$auth->destroy_session();
|
|
118 | 147 |
|
119 | 148 |
# remove the callback to display the message |
120 |
$form->{callback} = "login.pl?action=&login=";
|
|
149 |
$form->{callback} = "login.pl?action="; |
|
121 | 150 |
$form->redirect($locale->text('You are logged out!')); |
122 | 151 |
|
123 | 152 |
$lxdebug->leave_sub(); |
... | ... | |
126 | 155 |
sub company_logo { |
127 | 156 |
$lxdebug->enter_sub(); |
128 | 157 |
|
129 |
require "$userspath/$form->{login}.conf"; |
|
130 |
|
|
131 | 158 |
$locale = new Locale $myconfig{countrycode}, "login" if ($language ne $myconfig{countrycode}); |
132 | 159 |
|
133 | 160 |
$form->{stylesheet} = $myconfig{stylesheet}; |
... | ... | |
140 | 167 |
|
141 | 168 |
$lxdebug->leave_sub(); |
142 | 169 |
} |
170 |
|
|
171 |
sub show_error { |
|
172 |
my $template = shift; |
|
173 |
$locale = Locale->new($language, 'all'); |
|
174 |
$myconfig{countrycode} = $language; |
|
175 |
$form->{stylesheet} = 'css/lx-office-erp.css'; |
|
176 |
|
|
177 |
$form->header(); |
|
178 |
print $form->parse_html_template($template); |
|
179 |
|
|
180 |
# $form->parse_html_template('login/auth_db_unreachable'); |
|
181 |
# $form->parse_html_template('login/authentication_pl_missing'); |
|
182 |
|
|
183 |
exit; |
|
184 |
} |
Auch abrufbar als: Unified diff
Umstellung der Benutzerverwaltung von Dateien im Verzeichnis "users" auf die Verwendung einer Authentifizierungsdatenbank.
Es ist erforderlich, die Dateien doc/UPGRADE und doc/INSTALL/index.html zu lesen und die angesprochenen Punkte auszuführen, um nach einem Upgrade weiter arbeiten zu können.