Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 383534cc

Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt

  • ID 383534cc74519de23e1298cd5bb1fc542d836b42
  • Vorgänger 57528e5b
  • Nachfolger b3bc240d

Beim Login alle für diesen Mandanten gültigen User in employee anlegen

Unterschiede anzeigen:

SL/Controller/LoginScreen.pm
10 10
use SL::DB::AuthClient;
11 11
use SL::DB::AuthGroup;
12 12
use SL::DB::AuthUser;
13
use SL::DB::Employee;
13 14
use SL::Locale::String qw(t8);
14 15
use SL::User;
15 16

  
......
82 83
  # Everything is fine.
83 84
  $::auth->set_cookie_environment_variable();
84 85

  
85
  # TODO: Employees anlegen/checken
86
  # $self->_ensure_employees_for_authorized_users_exist;
87

  
88 86
  $self->_redirect_to_main_script;
89 87
}
90 88

  
......
106 104
sub _redirect_to_main_script {
107 105
  my ($self) = @_;
108 106

  
107
  $self->_ensure_employees_for_authorized_users_exist;
108

  
109 109
  return $self->redirect_to($::form->{callback}) if $::form->{callback};
110 110

  
111 111
  $self->redirect_to(controller => "login.pl", action => 'company_logo');
......
133 133
  return 1;
134 134
}
135 135

  
136
sub _ensure_employees_for_authorized_users_exist {
137
  my ($self) = @_;
138

  
139
  my %employees_by_login = map { ($_->login => $_) } @{ SL::DB::Manager::Employee->get_all };
140

  
141
  foreach my $user (@{ SL::DB::AuthClient->new(id => $::auth->client->{id})->load->users || [] }) {
142
    my $user_config = $user->config_values;
143
    my $employee    = $employees_by_login{$user->login} || SL::DB::Employee->new(login => $user->login);
144

  
145
    $employee->update_attributes(
146
      name      => $user_config->{name},
147
      workphone => $user_config->{tel},
148
      deleted   => 0,
149
    );
150
  }
151
}
152

  
136 153
sub error_state {
137 154
  return {
138 155
    session  => $::locale->text('The session is invalid or has expired.'),

Auch abrufbar als: Unified diff