History.pm 1.09 KB
Newer Older
Yadd's avatar
Yadd committed
1 2 3 4
package Lemonldap::NG::Portal::Plugins::History;

use strict;
use Mouse;
Yadd's avatar
Yadd committed
5
use Lemonldap::NG::Portal::Main::Constants qw(PE_INFO PE_OK);
Yadd's avatar
Yadd committed
6 7 8 9 10 11

extends 'Lemonldap::NG::Portal::Main::Plugin',
  'Lemonldap::NG::Portal::Lib::OtherSessions';

sub afterDatas { 'run' }

Yadd's avatar
Yadd committed
12 13
sub init { 1 }

Yadd's avatar
Yadd committed
14 15
sub run {
    my ( $self, $req ) = @_;
Yadd's avatar
Yadd committed
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
    if ( $req->param('checkLogins') ) {
        $self->logger->debug('History asked');
        $req->info(
            (
                $req->sessionInfo->{loginHistory}->{successLogin}
                ? $self->mkSessionArray(
                    $req->sessionInfo->{loginHistory}->{successLogin},
                    'lastLogins', 0, 0 )
                : ""
            )
            . (
                $req->sessionInfo->{loginHistory}->{failedLogin}
                ? $self->mkSessionArray(
                    $req->sessionInfo->{loginHistory}->{failedLogin},
                    'lastFailedLogins', 0, 1 )
                : ""
            )
        );
        unless($req->info) {
            $req->info('<p trspan="noHistory"></p>');
        }
        return PE_INFO;
    }
    return PE_OK;
Yadd's avatar
Yadd committed
40 41 42
}

1;