Changeset 1688


Ignore:
Timestamp:
01/28/16 16:47:36 (8 years ago)
Author:
nanardon
Message:

Avoid HTTP 500 error

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller/Root.pm

    r1687 r1688  
    7373    my ( $self, $c ) = @_; 
    7474 
    75     my $ouser = $c->model('Accounts')->db->get_object( 
    76         'user', 
    77         $c->user->{username}, 
    78     ); 
     75    if ($c->user->{username}) { 
     76        my $ouser = $c->model('Accounts')->db->get_object( 
     77            'user', 
     78            $c->user->{username}, 
     79        ); 
    7980 
    80     my @cd = split('-', DateTime->from_epoch( 
    81         epoch => str2time( 
    82             $ouser->get_attributes('create'), 
    83         ) 
    84     )->ymd('-')); 
    85     my @now = split('-', DateTime->now()->ymd('-')); 
    86  
    87     my ($Dy,$Dm,$Dd) = Date::Calc::N_Delta_YMD(@cd, @now); 
    88     $c->stash->{accountExists} = join(', ', 
    89         ($Dy ? $c->loc('[_1] years', $Dy)  : ()), 
    90         ($Dm ? $c->loc('[_1] months', $Dm) : ()), 
    91         ($Dd ? $c->loc('[_1] days', $Dd)   : ()), 
    92     ); 
    93  
    94     if (my $expire = $ouser->get_attributes('expire')) { 
    95         my @ed = split('-', DateTime->from_epoch( 
     81        my @cd = split('-', DateTime->from_epoch( 
    9682            epoch => str2time( 
    97                 $expire 
     83                $ouser->get_attributes('create'), 
    9884            ) 
    9985        )->ymd('-')); 
     86        my @now = split('-', DateTime->now()->ymd('-')); 
    10087 
    101         my ($Dy,$Dm,$Dd) = Date::Calc::N_Delta_YMD(@now, @ed); 
    102         $c->stash->{accountExpire} = join(', ', 
     88        my ($Dy,$Dm,$Dd) = Date::Calc::N_Delta_YMD(@cd, @now); 
     89        $c->stash->{accountExists} = join(', ', 
    10390            ($Dy ? $c->loc('[_1] years', $Dy)  : ()), 
    10491            ($Dm ? $c->loc('[_1] months', $Dm) : ()), 
    10592            ($Dd ? $c->loc('[_1] days', $Dd)   : ()), 
    10693        ); 
     94 
     95        if (my $expire = $ouser->get_attributes('expire')) { 
     96            my @ed = split('-', DateTime->from_epoch( 
     97                epoch => str2time( 
     98                    $expire 
     99                ) 
     100            )->ymd('-')); 
     101 
     102            my ($Dy,$Dm,$Dd) = Date::Calc::N_Delta_YMD(@now, @ed); 
     103            $c->stash->{accountExpire} = join(', ', 
     104                ($Dy ? $c->loc('[_1] years', $Dy)  : ()), 
     105                ($Dm ? $c->loc('[_1] months', $Dm) : ()), 
     106                ($Dd ? $c->loc('[_1] days', $Dd)   : ()), 
     107            ); 
     108        } 
    107109    } 
    108  
    109  
    110110} 
    111111 
Note: See TracChangeset for help on using the changeset viewer.