provide ability for admin to change account password
This commit is contained in:
parent
56b12f6555
commit
ad309f1036
64
Zotlabs/Module/Admin/Account_edit.php
Normal file
64
Zotlabs/Module/Admin/Account_edit.php
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Zotlabs\Module\Admin;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Account_edit {
|
||||||
|
|
||||||
|
function post() {
|
||||||
|
|
||||||
|
$account_id = $_REQUEST['aid'];
|
||||||
|
|
||||||
|
if(! $account_id)
|
||||||
|
return;
|
||||||
|
|
||||||
|
$pass1 = trim($_REQUEST['pass1']);
|
||||||
|
$pass2 = trim($_REQUEST['pass2']);
|
||||||
|
if($pass1 && $pass2 && ($pass1 === $pass2)) {
|
||||||
|
$salt = random_string(32);
|
||||||
|
$password_encoded = hash('whirlpool', $salt . $pass1);
|
||||||
|
$r = q("update account set account_salt = '%s', account_password = '%s',
|
||||||
|
account_password_changed = '%s' where account_id = %d",
|
||||||
|
dbesc($salt),
|
||||||
|
dbesc($password_encoded),
|
||||||
|
dbesc(datetime_convert()),
|
||||||
|
intval($account_id)
|
||||||
|
);
|
||||||
|
if($r)
|
||||||
|
info( sprintf( t('Password changed for account %d.'), $account_id). EOL);
|
||||||
|
|
||||||
|
}
|
||||||
|
goaway(z_root() . '/admin/accounts');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function get() {
|
||||||
|
if(argc() > 2)
|
||||||
|
$account_id = argv(2);
|
||||||
|
|
||||||
|
$x = q("select * from account where account_id = %d limit 1",
|
||||||
|
intval($account_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
if(! $x) {
|
||||||
|
notice ( t('Account not found.') . EOL);
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$a = replace_macros(get_markup_template('admin_account_edit.tpl'), [
|
||||||
|
'$account' => $x[0],
|
||||||
|
'$title' => t('Account Edit'),
|
||||||
|
'$pass1' => [ 'pass1', t('New Password'), ' ','' ],
|
||||||
|
'$pass2' => [ 'pass2', t('New Password again'), ' ','' ],
|
||||||
|
'$submit' => t('Submit'),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
return $a;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
14
view/tpl/admin_account_edit.tpl
Normal file
14
view/tpl/admin_account_edit.tpl
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<h2>{{$title}}</h2>
|
||||||
|
|
||||||
|
<h3>{{$account.account_email}}</h3>
|
||||||
|
|
||||||
|
|
||||||
|
<form action="admin/account_edit/{{$account.account_id}}" method="post" >
|
||||||
|
<input type="hidden" name="aid" value="{{$account.account_id}}" />
|
||||||
|
|
||||||
|
{{include file="field_password.tpl" field=$pass1}}
|
||||||
|
{{include file="field_password.tpl" field=$pass2}}
|
||||||
|
|
||||||
|
<input type="submit" name="submit" value="{{$submit}}" />
|
||||||
|
|
||||||
|
</form>
|
@ -62,9 +62,9 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td class="account_id">{{$u.account_id}}</td>
|
<td class="account_id">{{$u.account_id}}</td>
|
||||||
<td class="email">{{if $u.blocked}}
|
<td class="email">{{if $u.blocked}}
|
||||||
<i>{{$u.account_email}}</i>
|
<a href="admin/account_edit/{{$u.account_id}}"><i>{{$u.account_email}}</i></a>
|
||||||
{{else}}
|
{{else}}
|
||||||
<strong>{{$u.account_email}}</strong>
|
<a href="admin/account_edit/{{$u.account_id}}"><strong>{{$u.account_email}}</strong></a>
|
||||||
{{/if}}</td>
|
{{/if}}</td>
|
||||||
<td class="channels">{{$u.channels}}</td>
|
<td class="channels">{{$u.channels}}</td>
|
||||||
<td class="register_date">{{$u.account_created}}</td>
|
<td class="register_date">{{$u.account_created}}</td>
|
||||||
|
Reference in New Issue
Block a user