Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 540c0b5e

Von Moritz Bunkus vor etwa 12 Jahren hinzugefügt

User-Login auf Controller umgestellt

Unterschiede anzeigen:

bin/mozilla/login.pl
41 41
our $form;
42 42
our $auth;
43 43

  
44
sub run {
45
  $::lxdebug->enter_sub;
46
  my $session_result = shift;
47

  
48
  $form   = $::form;
49
  $auth   = $::auth;
50

  
51
  $form->{stylesheet} = "lx-office-erp.css";
52
  $form->{favicon}    = "favicon.ico";
53

  
54
  if (SL::Auth::SESSION_EXPIRED == $session_result) {
55
    $form->{error_message} = $::locale->text('The session is invalid or has expired.');
56
    login_screen();
57
    ::end_of_request();
58
  }
59
  my $action = $form->{action};
60
  if (!$action && $auth->{SESSION}->{login}) {
61
    $action = 'login';
62
  }
63
  if ($action) {
64
    $form->{login} = $form->{'{AUTH}login'} || $form->{login};
65
    %::myconfig    = $auth->read_user(login => $form->{login}) if $form->{login};
66

  
67
    $::locale   = Locale->new($::myconfig{countrycode}) if $::myconfig{countrycode};
68

  
69
    if (SL::Auth::OK != $auth->authenticate($::myconfig{login}, $form->{'{AUTH}password'})) {
70
      $form->{error_message} = $::locale->text('Incorrect username or password!');
71
      login_screen();
72
    } else {
73
      $auth->create_or_refresh_session();
74
      delete $form->{'{AUTH}password'};
75

  
76
      $form->{titlebar} .= " - $::myconfig{name} - $::myconfig{dbname}";
77
      call_sub($::locale->findsub($action));
78
    }
79
  } else {
80
    login_screen();
81
  }
82

  
83
  $::lxdebug->leave_sub;
84
}
85

  
86
sub login_screen {
87
  $main::lxdebug->enter_sub();
88
  my ($msg) = @_;
89

  
90
  if (-f "css/lx-office-erp.css") {
91
    $form->{stylesheet} = "lx-office-erp.css";
92
  }
93

  
94
  $form->{msg} = $msg;
95
  $form->header();
96

  
97
  print $form->parse_html_template('login/login_screen');
98

  
99
  $main::lxdebug->leave_sub();
100
}
101

  
102
sub login {
103
  $main::lxdebug->enter_sub();
104

  
105
  unless ($form->{login}) {
106
    login_screen($::locale->text('You did not enter a name!'));
107
    ::end_of_request();
108
  }
109

  
110
  my $user = User->new(login => $form->{login});
111

  
112
  # if we get an error back, bale out
113
  my $result;
114
  if (($result = $user->login($form)) <= -1) {
115
    if ($result == -3) {
116
      show_error('login/auth_db_needs_update');
117
      $::auth->destroy_session;
118
      ::end_of_request();
119
    }
120

  
121
    ::end_of_request() if $result == -2;
122
    login_screen($::locale->text('Incorrect username or password!'));
123
    ::end_of_request();
124
  }
125

  
126
  my %style_to_script_map = (
127
    v3  => 'v3',
128
    neu => 'new',
129
    v4  => 'v4',
130
  );
131

  
132
  my $menu_script = $style_to_script_map{$user->{menustyle}} || '';
133

  
134
  # made it this far, execute the menu
135
  # standard redirect does not seem to work for this invocation, (infinite loops?)
136
  # do a manual invocation instead
137
#  $form->{callback} = build_std_url("script=menu${menu_script}.pl", 'action=display', "callback=" . $form->escape($form->{callback}));
138

  
139
  $main::auth->set_cookie_environment_variable();
140

  
141
  $::form->{script}   = "menu${menu_script}.pl";
142
  $::form->{action}   = 'display';
143
  $::form->{callback} = $::form->escape($::form->{callback});
144

  
145
  require "bin/mozilla/$::form->{script}";
146
  display();
147

  
148
#  $form->redirect();
149

  
150
  $main::lxdebug->leave_sub();
151
}
152

  
153
sub logout {
154
  $main::lxdebug->enter_sub();
155

  
156
  $main::auth->destroy_session();
157

  
158
  # remove the callback to display the message
159
  $form->{callback} = "login.pl?action=";
160
  $form->redirect($::locale->text('You are logged out!'));
161

  
162
  $main::lxdebug->leave_sub();
163
}
164

  
165 44
sub company_logo {
166 45
  $main::lxdebug->enter_sub();
167 46

  
......
180 59
  $main::lxdebug->leave_sub();
181 60
}
182 61

  
183
sub show_error {
184
  my $template           = shift;
185
  my %myconfig           = %main::myconfig;
186
  $myconfig{countrycode} = $::lx_office_conf{system}->{language};
187
  $form->{stylesheet}    = 'css/lx-office-erp.css';
188

  
189
  $form->header();
190
  print $form->parse_html_template($template);
191

  
192
  # $form->parse_html_template('login/auth_db_unreachable');
193
  # $form->parse_html_template('login/auth_db_needs_update');
194
  # $form->parse_html_template('login/authentication_pl_missing');
195

  
196
  ::end_of_request();
197
}
198

  
199 62
1;
200 63

  
201 64
__END__

Auch abrufbar als: Unified diff