aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
authorredmatrix <mike@macgirvin.com>2016-09-30 15:42:14 -0700
committerredmatrix <mike@macgirvin.com>2016-09-30 15:42:14 -0700
commitad309f1036d9d85899c3d3199070d92dd96b1710 (patch)
tree426022b6c88814c72d4c9939a60f43b08e819e7c /Zotlabs
parent56b12f655546dc122e734654e1d5e5fc6dd06c43 (diff)
downloadvolse-hubzilla-ad309f1036d9d85899c3d3199070d92dd96b1710.tar.gz
volse-hubzilla-ad309f1036d9d85899c3d3199070d92dd96b1710.tar.bz2
volse-hubzilla-ad309f1036d9d85899c3d3199070d92dd96b1710.zip
provide ability for admin to change account password
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Module/Admin/Account_edit.php64
1 files changed, 64 insertions, 0 deletions
diff --git a/Zotlabs/Module/Admin/Account_edit.php b/Zotlabs/Module/Admin/Account_edit.php
new file mode 100644
index 000000000..ddb7e19f4
--- /dev/null
+++ b/Zotlabs/Module/Admin/Account_edit.php
@@ -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;
+
+
+ }
+
+
+} \ No newline at end of file