Revision 81a9ce9b
Von Sven Schöling vor mehr als 8 Jahren hinzugefügt
SL/Auth.pm | ||
---|---|---|
592 | 592 |
sub _load_with_auto_restore_column { |
593 | 593 |
my ($self, $dbh, $session_id) = @_; |
594 | 594 |
|
595 |
my $auto_restore_keys = join ', ', map { "'${_}'" } qw(login password rpw client_id), SESSION_KEY_ROOT_AUTH, SESSION_KEY_USER_AUTH;
|
|
595 |
my %auto_restore_keys = map { $_ => 1 } qw(login password rpw client_id), SESSION_KEY_ROOT_AUTH, SESSION_KEY_USER_AUTH;
|
|
596 | 596 |
|
597 | 597 |
my $query = <<SQL; |
598 | 598 |
SELECT sess_key, sess_value, auto_restore |
599 | 599 |
FROM auth.session_content |
600 | 600 |
WHERE (session_id = ?) |
601 |
AND ( auto_restore |
|
602 |
OR sess_key IN (${auto_restore_keys})) |
|
603 | 601 |
SQL |
604 | 602 |
my $sth = prepare_execute_query($::form, $dbh, $query, $session_id); |
605 | 603 |
|
606 | 604 |
while (my $ref = $sth->fetchrow_hashref) { |
607 |
my $value = SL::Auth::SessionValue->new(auth => $self, |
|
608 |
key => $ref->{sess_key}, |
|
609 |
value => $ref->{sess_value}, |
|
610 |
auto_restore => $ref->{auto_restore}, |
|
611 |
raw => 1); |
|
612 |
$self->{SESSION}->{ $ref->{sess_key} } = $value; |
|
613 |
|
|
614 |
next if defined $::form->{$ref->{sess_key}}; |
|
615 |
|
|
616 |
my $data = $value->get; |
|
617 |
$::form->{$ref->{sess_key}} = $data if $value->{auto_restore} || !ref $data; |
|
605 |
if ($ref->{auto_restore} || $auto_restore_keys{$ref->{sess_key}}) { |
|
606 |
my $value = SL::Auth::SessionValue->new(auth => $self, |
|
607 |
key => $ref->{sess_key}, |
|
608 |
value => $ref->{sess_value}, |
|
609 |
auto_restore => $ref->{auto_restore}, |
|
610 |
raw => 1); |
|
611 |
$self->{SESSION}->{ $ref->{sess_key} } = $value; |
|
612 |
|
|
613 |
next if defined $::form->{$ref->{sess_key}}; |
|
614 |
|
|
615 |
my $data = $value->get; |
|
616 |
$::form->{$ref->{sess_key}} = $data if $value->{auto_restore} || !ref $data; |
|
617 |
} else { |
|
618 |
my $value = SL::Auth::SessionValue->new(auth => $self, |
|
619 |
key => $ref->{sess_key}); |
|
620 |
$self->{SESSION}->{ $ref->{sess_key} } = $value; |
|
621 |
} |
|
618 | 622 |
} |
619 | 623 |
|
620 | 624 |
$sth->finish; |
621 |
|
|
622 |
$query = <<SQL; |
|
623 |
SELECT sess_key |
|
624 |
FROM auth.session_content |
|
625 |
WHERE (session_id = ?) |
|
626 |
AND NOT COALESCE(auto_restore, FALSE) |
|
627 |
AND (sess_key NOT IN (${auto_restore_keys})) |
|
628 |
SQL |
|
629 |
$sth = prepare_execute_query($::form, $dbh, $query, $session_id); |
|
630 |
|
|
631 |
while (my $ref = $sth->fetchrow_hashref) { |
|
632 |
my $value = SL::Auth::SessionValue->new(auth => $self, |
|
633 |
key => $ref->{sess_key}); |
|
634 |
$self->{SESSION}->{ $ref->{sess_key} } = $value; |
|
635 |
} |
|
636 | 625 |
} |
637 | 626 |
|
638 | 627 |
sub destroy_session { |
Auch abrufbar als: Unified diff
Auth: session content mit einem sql query holen statt zwei.