| 14 | |
| 15 | == check password == |
| 16 | edit file /omd/versions/4.40-labs-edition/share/thruk/plugins/plugins-available/conf/lib/Thruk/Controller/conf.pm |
| 17 | {{{ |
| 18 | # change password? |
| 19 | if($c->req->parameters->{'save'}) { |
| 20 | return unless Thruk::Utils::check_csrf($c); |
| 21 | |
| 22 | my $old = $c->req->parameters->{'data.old'} || ''; |
| 23 | my $pass1 = $c->req->parameters->{'data.password'} || ''; |
| 24 | my $pass2 = $c->req->parameters->{'data.password2'} || ''; |
| 25 | my $min_length = $c->config->{'user_password_min_length'} || 5; |
| 26 | if($has_minus_v && !$old) { |
| 27 | Thruk::Utils::set_message($c, 'fail_message', "Current password missing"); |
| 28 | } |
| 29 | elsif($pass1 eq '' || $pass2 eq '') { |
| 30 | Thruk::Utils::set_message($c, 'fail_message', "New password cannot be empty"); |
| 31 | } |
| 32 | # check pass1 has any UPPER char |
| 33 | elsif($pass1 !~ /[A-Z]/ ) { |
| 34 | Thruk::Utils::set_message($c, 'fail_message', "New password should contain some UPPER case"); |
| 35 | } |
| 36 | # check pass1 has any digit |
| 37 | elsif($pass1 !~ /[0-9]/ ) { |
| 38 | Thruk::Utils::set_message($c, 'fail_message', "New password should contain some Digit "); |
| 39 | } |
| 40 | # check pass1 has any @ # * = symbol |
| 41 | elsif($pass1 !~ /[@#*=]/ ) { |
| 42 | Thruk::Utils::set_message($c, 'fail_message', "New password should contain some symbol @#*= "); |
| 43 | } |
| 44 | # check pass1 =~ mean match any space bar |
| 45 | elsif($pass1 =~ / / ) { |
| 46 | Thruk::Utils::set_message($c, 'fail_message', "New password contain some white space "); |
| 47 | } |
| 48 | #elsif($pass1 =~ /^\d*$/) { |
| 49 | # Thruk::Utils::set_message($c, 'fail_message', "New password contain only number"); |
| 50 | #} |
| 51 | #elsif($pass1 =~ /[^\w\s]/) { |
| 52 | # Thruk::Utils::set_message($c, 'fail_message', "New password contain non char"); |
| 53 | #} |
| 54 | elsif(length($pass1) < $min_length) { |
| 55 | Thruk::Utils::set_message($c, 'fail_message', "New password must have at least ".$min_length." characters."); |
| 56 | } |
| 57 | #elsif($pass1 ne '' && $pass1 eq $pass2) { |
| 58 | elsif($pass1 ne '' && $pass1 eq $pass2 ) { |
| 59 | my $err = _htpasswd_password($c, $user, $pass1, $old); |
| 60 | if($err) { |
| 61 | _error("changing password for ".$user." failed: ".$err); |
| 62 | Thruk::Utils::set_message($c, 'fail_message', "Password change failed."); |
| 63 | } else { |
| 64 | _audit_log("configtool", "new password set for user ".$user); |
| 65 | Thruk::Utils::set_message($c, 'success_message', "Password changed successfully"); |
| 66 | } |
| 67 | } |
| 68 | return $c->redirect_to('conf.cgi?action=user_password'); |
| 69 | } |
| 70 | }}} |