Commit 1cd459f3 authored by Roberto P. Rubio's avatar Roberto P. Rubio
Browse files

Adds form to change user passwd

parent c614b484
......@@ -511,14 +511,22 @@ Arguments: password
sub change_password {
my $self = shift;
my $password = shift or die "ERROR: password required\n";
my ($force_change_password) = @_;
_init_connector();
die "Password too small" if length($password)<6;
my $sth= $$CON->dbh->prepare("UPDATE users set password=?"
." WHERE name=?");
$sth->execute(sha1_hex($password), $self->name);
my $sth;
if (defined($force_change_password)) {
$sth= $$CON->dbh->prepare("UPDATE users set password=?, change_password=?"
." WHERE name=?");
$sth->execute(sha1_hex($password), $force_change_password ? 1 : 0, $self->name);
} else {
my $sth= $$CON->dbh->prepare("UPDATE users set password=?"
." WHERE name=?");
$sth->execute(sha1_hex($password), $self->name);
}
}
=head2 compare_password
......
......@@ -1087,6 +1087,9 @@ any '/admin/user/(:id).(:type)' => sub {
}
}
}
if ($c->param('set_password')) {
$user->change_password($c->param('password'), $c->param('force_change_password'));
}
$c->stash(user => $user);
return $c->render(template => 'main/manage_user');
};
......
......@@ -21,6 +21,11 @@
<li class="nav-item">
<a class="nav-link" href="#grants" role="tab" data-toggle="tab" aria-controls="grants" aria-selected="true">Grants</a>
</li>
% }
% if (( $_user->is_admin ) && (! $_user->is_external)) {
<li class="nav-item">
<a class="nav-link" href="#password" role="tab" data-toggle="tab" aria-controls="password" aria-selected="true">Password</a>
</li>
% }
</ul>
<div class="tab-content" id="myTabContent">
......@@ -33,6 +38,11 @@
<div class="tab-pane fade" id="grants" role="tabpanel" aria-labelledby="grants-tab">
%= include '/main/manage_user_grants'
</div>
% }
% if (( $_user->is_admin ) && (! $_user->is_external)) {
<div class="tab-pane fade" id="password" role="tabpanel" aria-labelledby="password-tab">
%= include '/main/manage_user_password'
</div>
% }
</div>
</div><! --page-header -->
......
<div class="card">
<div class="card-body">
<form method="post">
<label for="password"><%=l 'New password' %></label><br/>
<input type="text" name="password">
<br>
<br>
<input type="checkbox" name="force_change_password" value="1" checked>
<label for="force_change_password"><%=l 'Force change password on first access' %></label><br/>
<input type="submit" class="btn btn-primary" name="set_password" value="<%=l 'Set New Password' %>" onclick="return ((password.value) && (password.value.length >= 6)) ? true : false;">
</form>
</div>
</div>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment