Ignore:
Timestamp:
04/28/17 10:54:50 (7 years ago)
Author:
nanardon
Message:

Improve loadpasswd feature

Location:
trunk/LATMOS-Accounts-Web
Files:
5 edited

Legend:

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

    r2003 r2006  
    22use Moose; 
    33use namespace::autoclean; 
     4 
     5use LATMOS::Accounts::Log; 
    46 
    57BEGIN { extends 'Catalyst::Controller'; } 
     
    2527    my ( $self, $c ) = @_; 
    2628 
    27     my $account = $c->model('Account'); 
     29    my $account = $c->model('Accounts'); 
    2830 
    2931    if (my $upload = $c->req->upload('input')) { 
    3032 
    3133        my $crypt = $c->req->param('crypt'); 
     34        my $force = $c->req->param('force'); 
    3235 
    3336        my $fh =  $upload->fh; 
    3437        while (my $line = <$fh>) { 
    35             my ($username, $password) = split(/:/); 
     38            my ($username, $password) = split(/:/, $line); 
    3639            $username or next; 
    3740            $password or next; 
    3841 
    3942            if ($crypt) { 
    40                 my $user = $c->model('Accounts')->db->get_objects('user', $username) 
    41                     or next; 
    42                 $user->InjectCryptPasswd($password); 
     43                my $user = $account->db->get_objects('user', $username) 
     44                    or do { 
     45                    push(@{ $c->stash->{Pass} }, { u => $username, r => 'No such user' });   
     46                    next; 
     47                }; 
     48                $account->db->check_acl($user, 'userPassword', 'w')  
     49                    or do { 
     50                    push(@{ $c->stash->{Pass} }, { u => $username, r => 'Permission denied' });   
     51                    next; 
     52                }; 
     53 
     54                if ($user->InjectCryptPasswd($password)) { 
     55                    push(@{ $c->stash->{Pass} }, { u => $username, r => 'Injected' }); 
     56                } else { 
     57                    push(@{ $c->stash->{Pass} }, { u => $username, r => 'Error: ' . LATMOS::Accounts::Log::lastmessage(LA_ERR) }); 
     58                } 
    4359            } else { 
    44                 $c->model('Accounts')->ChangeUserPassword($username, $password); 
     60                my $message = $account->ChangeUserPassword($username, $password, $force); 
     61                push(@{ $c->stash->{Pass} }, { u => $username, r => $message || 'Changed' }); 
    4562            } 
    4663        } 
    4764    } 
    4865} 
    49  
    50  
    5166 
    5267=encoding utf8 
  • trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/I18N/fr.po

    r1993 r2006  
    4646msgstr "(autre)" 
    4747 
    48 #: root/html/includes/sidebar.tt:94 
     48#: root/html/includes/sidebar.tt:104 
    4949msgid "About" 
    5050msgstr "À propos" 
     
    125125msgstr "Départ" 
    126126 
     127#: root/html/includes/sidebar.tt:97 
     128msgid "Load Password" 
     129msgstr "" 
     130 
    127131#: root/html/includes/sidebar.tt:20 
    128132msgid "Logout" 
     
    139143#: root/html/tools/csv/parseCSV.tt:24 
    140144msgid "Object Name" 
     145msgstr "" 
     146 
     147#: root/html/tools/loadnew/index.tt:22 
     148msgid "Object data:" 
     149msgstr "" 
     150 
     151#: root/html/tools/loadnew/index.tt:17 
     152msgid "Object name (optional):" 
    141153msgstr "" 
    142154 
     
    213225msgstr "Aujourd'hui" 
    214226 
     227#: root/html/includes/sidebar.tt:93 
     228msgid "Tools" 
     229msgstr "Outils" 
     230 
    215231#: root/html/tools/csv/index.tt:21 
    216232msgid "Type of object to create" 
     233msgstr "" 
     234 
     235#: root/html/tools/loadnew/index.tt:4 
     236msgid "Type of object to create:" 
    217237msgstr "" 
    218238 
     
    230250msgstr "Bienvenue %1." 
    231251 
     252#: root/html/tools/loadnew/index.tt:23 
     253msgid "You can load a existing file..." 
     254msgstr "" 
     255 
    232256#. (c.stash.accountExists) 
    233257#: root/html/about/index.tt:5 
     
    240264msgstr "Votre compte exprirera dans %1, Nous vraiment désolé." 
    241265 
     266#: root/html/tools/loadnew/index.tt:27 
     267msgid "or paste the content here:" 
     268msgstr "" 
     269 
    242270#: root/html/users/employment.tt:29 root/html/users/employment.tt:92 
    243271msgid "to" 
     
    247275#~ msgid "From CVS" 
    248276#~ msgstr "Du" 
    249  
    250 #~ msgid "Tools" 
    251 #~ msgstr "Outils" 
  • trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/I18N/messages.pot

    r1993 r2006  
    3939msgstr "" 
    4040 
    41 #: root/html/includes/sidebar.tt:94 
     41#: root/html/includes/sidebar.tt:104 
    4242msgid "About" 
    4343msgstr "" 
     
    115115msgstr "" 
    116116 
     117#: root/html/includes/sidebar.tt:97 
     118msgid "Load Password" 
     119msgstr "" 
     120 
    117121#: root/html/includes/sidebar.tt:20 
    118122msgid "Logout" 
     
    129133#: root/html/tools/csv/parseCSV.tt:24 
    130134msgid "Object Name" 
     135msgstr "" 
     136 
     137#: root/html/tools/loadnew/index.tt:22 
     138msgid "Object data:" 
     139msgstr "" 
     140 
     141#: root/html/tools/loadnew/index.tt:17 
     142msgid "Object name (optional):" 
    131143msgstr "" 
    132144 
     
    201213msgstr "" 
    202214 
     215#: root/html/includes/sidebar.tt:93 
     216msgid "Tools" 
     217msgstr "" 
     218 
    203219#: root/html/tools/csv/index.tt:21 
    204220msgid "Type of object to create" 
     221msgstr "" 
     222 
     223#: root/html/tools/loadnew/index.tt:4 
     224msgid "Type of object to create:" 
    205225msgstr "" 
    206226 
     
    218238msgstr "" 
    219239 
     240#: root/html/tools/loadnew/index.tt:23 
     241msgid "You can load a existing file..." 
     242msgstr "" 
     243 
    220244#. (c.stash.accountExists) 
    221245#: root/html/about/index.tt:5 
     
    228252msgstr "" 
    229253 
     254#: root/html/tools/loadnew/index.tt:27 
     255msgid "or paste the content here:" 
     256msgstr "" 
     257 
    230258#: root/html/users/employment.tt:29 root/html/users/employment.tt:92 
    231259msgid "to" 
  • trunk/LATMOS-Accounts-Web/root/html/includes/sidebar.tt

    r1993 r2006  
    9191</li> 
    9292 
     93<li>[% l('Tools') %] 
     94    <ul> 
     95    [% IF c.model('Accounts').db.check_acl('user', 'userPasswd', 'w') %] 
     96    <li><a href="[% c.uri_for('/tools', 'loadpasswd') %]"> 
     97        [% l('Load Password') %] 
     98    </a></li> 
     99    [% END %] 
     100    </ul> 
     101</li> 
     102 
    93103<li><a href="[% c.uri_for('/about') %]"> 
    94104    [% l('About') %]</a></li> 
  • trunk/LATMOS-Accounts-Web/root/html/tools/loadpasswd/index.tt

    r2003 r2006  
    11<form action="[% c.uri_for('/tools', 'loadpasswd') %]" method="post" 
    22    enctype="multipart/form-data"> 
     3 
     4<p>[% l('The file format must similar to UNIX standard password, only the two 
     5first column are used.') %]</p> 
     6 
     7<pre> 
     8username1:password1:.... 
     9username2:password2:.... 
     10</pre> 
    311 
    412<p>[% l('When password are encrypted they are injected only in 
     
    816<input type=checkbox name=crypt> 
    917<br> 
     18<label for=crypt>[% l('Dont check for weak passord') | html %]</label> 
     19<input type=checkbox name=force> 
     20<br> 
    1021<label for=file>[% l('You can load a existing file...') | html %]</label> 
    1122<br> 
     
    1425<input type="submit"> 
    1526</form> 
     27 
     28[% FOREACH res = Pass %] 
     29[% IF loop.first %] 
     30<p>[% l('Results:') %]</p> 
     31<table border=1> 
     32<tr> 
     33<td>[% l('Username') | html %]</td> 
     34<td>[% l('Results') | html %]</td> 
     35</tr> 
     36[% END %] 
     37<tr> 
     38<td>[% res.u | html %]</td> 
     39<td>[% res.r | html %]</td> 
     40</tr> 
     41[% IF loop.last %] 
     42</table> 
     43[% END %] 
     44[% END %] 
Note: See TracChangeset for help on using the changeset viewer.