Revision f3f0322b
Von Sven Schöling vor mehr als 13 Jahren hinzugefügt
SL/Auth.pm | ||
---|---|---|
46 | 46 |
} |
47 | 47 |
|
48 | 48 |
sub get_user_dbh { |
49 |
my ($self, $login) = @_; |
|
49 |
my ($self, $login, %params) = @_; |
|
50 |
my $may_fail = delete $params{may_fail}; |
|
51 |
|
|
50 | 52 |
my %user = $self->read_user($login); |
51 | 53 |
my $dbh = SL::DBConnect->connect( |
52 | 54 |
$user{dbconnect}, |
... | ... | |
56 | 58 |
pg_enable_utf8 => $::locale->is_utf8, |
57 | 59 |
AutoCommit => 0 |
58 | 60 |
} |
59 |
) or $::form->dberror; |
|
61 |
); |
|
62 |
|
|
63 |
if (!$may_fail && !$dbh) { |
|
64 |
$::form->error($::locale->text('The connection to the authentication database failed:') . "\n" . $DBI::errstr); |
|
65 |
} |
|
60 | 66 |
|
61 |
if ($user{dboptions}) { |
|
67 |
if ($user{dboptions} && $dbh) {
|
|
62 | 68 |
$dbh->do($user{dboptions}) or $::form->dberror($user{dboptions}); |
63 | 69 |
} |
64 | 70 |
|
... | ... | |
430 | 436 |
} |
431 | 437 |
|
432 | 438 |
sub delete_user { |
433 |
$main::lxdebug->enter_sub();
|
|
439 |
$::lxdebug->enter_sub;
|
|
434 | 440 |
|
435 | 441 |
my $self = shift; |
436 | 442 |
my $login = shift; |
437 | 443 |
|
438 |
my $form = $main::form; |
|
439 |
|
|
440 |
my %user = $self->read_user($login); |
|
441 |
my $u_dbh = DBI->connect($user{dbconnect}, $user{dbuser}, $user{dbpasswd}); |
|
442 |
|
|
443 |
my $dbh = $self->dbconnect(); |
|
444 |
my $u_dbh = $self->get_user_dbh($login, may_fail => 1); |
|
445 |
my $dbh = $self->dbconnect; |
|
444 | 446 |
|
445 | 447 |
$dbh->begin_work; |
446 | 448 |
|
447 | 449 |
my $query = qq|SELECT id FROM auth."user" WHERE login = ?|; |
448 | 450 |
|
449 |
my ($id) = selectrow_query($form, $dbh, $query, $login); |
|
451 |
my ($id) = selectrow_query($::form, $dbh, $query, $login);
|
|
450 | 452 |
|
451 |
$dbh->rollback and return $main::lxdebug->leave_sub() if (!$id);
|
|
453 |
$dbh->rollback and return $::lxdebug->leave_sub if (!$id);
|
|
452 | 454 |
|
453 |
do_query($form, $dbh, qq|DELETE FROM auth.user_group WHERE user_id = ?|, $id); |
|
454 |
do_query($form, $dbh, qq|DELETE FROM auth.user_config WHERE user_id = ?|, $id); |
|
455 |
do_query($form, $u_dbh, qq|UPDATE employee SET deleted = 't' WHERE login = ?|, $login);
|
|
455 |
do_query($::form, $dbh, qq|DELETE FROM auth.user_group WHERE user_id = ?|, $id);
|
|
456 |
do_query($::form, $dbh, qq|DELETE FROM auth.user_config WHERE user_id = ?|, $id);
|
|
457 |
do_query($::form, $u_dbh, qq|UPDATE employee SET deleted = 't' WHERE login = ?|, $login) if $u_dbh;
|
|
456 | 458 |
|
457 | 459 |
$dbh->commit; |
458 |
$u_dbh->commit; |
|
460 |
$u_dbh->commit if $u_dbh;
|
|
459 | 461 |
|
460 |
$main::lxdebug->leave_sub();
|
|
462 |
$::lxdebug->leave_sub;
|
|
461 | 463 |
} |
462 | 464 |
|
463 | 465 |
# -------------------------------------- |
Auch abrufbar als: Unified diff
Löschen von usern ermöglichen, wenn die Datenbank nicht existiert oder falsch eingetragen ist.