Changeset 1405


Ignore:
Timestamp:
08/31/15 17:57:50 (9 years ago)
Author:
nanardon
Message:

Fix password change when user does not exists, trap more errors

Location:
trunk
Files:
4 edited

Legend:

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

    r1403 r1405  
    4444    # synchaccess do not manage connect() at time, opening a 
    4545    # backdoor then :\ 
    46     foreach ($sync->bases) { $_->{_user} = $username } 
    47  
    48     my $suser = $sync->get_object('user', $username); 
     46    foreach ($sync->bases) { $_->{_user} = $c->user->username } 
     47 
     48    my $suser = $sync->get_object_ifexists('user', $username); 
    4949    my $msg = $c->stash->{user}->check_password($password); 
    5050    if ($msg ne 'ok') { 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts.pm

    r1354 r1405  
    268268        ); 
    269269    } 
     270 
     271    if (!@obases) { 
     272        la_log(LA_ERR, "Cannot load any bases for syncronised action"); 
     273        return; 
     274    } 
     275 
     276    la_log(LA_DEBUG, "Load databases: %s", join(', ', map { $_->label } @obases)); 
    270277 
    271278    LATMOS::Accounts::SynchAccess->new([ @obases ]); 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/SynchAccess.pm

    r1023 r1405  
    1717=cut  
    1818 
    19 # TODO WTF is difference with LATMOS::Accounts::SynchAccess::base 
    20  
    2119=head2 get_object ($otype, $uid) 
    2220 
    23 Compatibility function: return a set of object for which action must be done. 
     21Compatibility function: return a set of objects for which action must be done. 
    2422 
    2523=cut 
     
    3129        if ($_->is_supported_object($otype)) { 
    3230            my $u = $_->get_object($otype, $uid) or do { 
    33                 la_log(LA_ERR, 
    34                     "Cannot get object $otype/$uid in %s/%s", 
    35                     $_->type, 
    36                     $_->label 
     31                $_->log(LA_ERR, 
     32                    "Cannot get object $otype/$uid", 
    3733                ); 
    3834                return; 
    39                 }; 
     35            }; 
    4036            push(@subobj, $u); 
    4137        } 
    4238    } 
     39 
     40    return LATMOS::Accounts::SynchAccess::Objects->new( 
     41        [ @subobj ] 
     42    ); 
     43} 
     44 
     45=head2 get_object_ifexists ($otype, $uid) 
     46 
     47Compatibility function: return a set of objects for which action must be done. 
     48 
     49Instead get_object, if the named object does not exists in a database no error is returned 
     50 
     51=cut 
     52 
     53sub get_object_ifexists { 
     54    my ($self, $otype, $uid) = @_; 
     55    my @subobj; 
     56    foreach ($self->bases) { 
     57        $_->log(LA_DEBUG, 
     58            "trying to get object $otype/$uid", 
     59        ); 
     60        if ($_->is_supported_object($otype)) { 
     61            my $u = $_->get_object($otype, $uid) or do { 
     62                $_->log(LA_WARN, 
     63                    "Cannot get object $otype/$uid", 
     64                ); 
     65                next 
     66            }; 
     67            push(@subobj, $u); 
     68        } 
     69    } 
     70 
     71    if (!@subobj) { 
     72        la_log(LA_ERR, "No object $otype/$uid found in any bases"); 
     73        return; 
     74    } 
     75 
    4376    return LATMOS::Accounts::SynchAccess::Objects->new( 
    4477        [ @subobj ] 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/SynchAccess/base.pm

    r1262 r1405  
    1717This module fake a base object to send same actions tu multiple base. This is 
    1818used for actions basic synchronisation process cannot handle. 
     19 
     20This module contain common functions between Base and Object managment. 
    1921 
    2022=head1 FUNCTIONS 
Note: See TracChangeset for help on using the changeset viewer.