From bfc01166c5a457ac67657ff97e2c055be82e6efc Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Fri, 21 Nov 2014 14:45:38 +1000 Subject: [PATCH] * ability to change password --- lib/LDV/I18N/ru.pm | 1 + lib/LDV/User.pm | 5 +++++ templates/user/profile.html.ep | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/lib/LDV/I18N/ru.pm b/lib/LDV/I18N/ru.pm index 1393935..6558430 100644 --- a/lib/LDV/I18N/ru.pm +++ b/lib/LDV/I18N/ru.pm @@ -14,6 +14,7 @@ our %Lexicon = 'Login' => 'Имя входа', 'Log in' => 'Войти', 'Password' => 'Пароль', + 'New password' => 'Новый пароль', 'Current password' => 'Действующий пароль', 'Display name' => 'Отображаемое имя', 'Email' => 'Эл. почта', diff --git a/lib/LDV/User.pm b/lib/LDV/User.pm index c50d990..de0cdd1 100644 --- a/lib/LDV/User.pm +++ b/lib/LDV/User.pm @@ -109,6 +109,11 @@ sub update { } my $error = $self->app->ldap->update($user, \%attrs); die("$error\n") if $error; + if ($self->app->config->{user}->{allow_chpass} and + my $newpass = $self->req->param('newpass')) { + $error = $self->app->ldap->chpass($user, $newpass); + die("$error\n") if $error; + } $self->redirect_to('/user/profile'); 1; } or do { $self->flash({result => "Can't save profile: $@"}); diff --git a/templates/user/profile.html.ep b/templates/user/profile.html.ep index 35c8d13..7fe0269 100644 --- a/templates/user/profile.html.ep +++ b/templates/user/profile.html.ep @@ -33,6 +33,12 @@ <%= l('Avatar') %> <%= file_field 'photo' %> +% if (config->{user}->{allow_chpass}) { + + <%= l('New password') %> + <%= password_field 'newpass', placeholder => '******' %> + +% }
<%= l('Current password') %>