From 34bd29bf00001d89500348f22130a3cb499b126d Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 17 Aug 2006 01:53:29 +0000 Subject: [PATCH] Added change password UI. --- php_interface/queue.php | 122 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/php_interface/queue.php b/php_interface/queue.php index f7a431d..1fd2a8b 100644 --- a/php_interface/queue.php +++ b/php_interface/queue.php @@ -17,6 +17,7 @@ 'post' => do_post, 'newuser' => do_newuser, 'forgotpw' => do_forgotpw, + 'changepw' => do_changepw, 'createqueue' => do_createqueue, 'unknown' => do_unknown ); @@ -183,6 +184,119 @@ function get_connected(&$sock) } // get_connected +function output_changepw_widgets() +{ + echo << + + + +
+
+ + + + + + + + + + + + +
New password:
Retype new password:
+ + + + + + +
+ + New user + + + + + + Forgot password + +
+
+
+
+ +EOF; +} // output_changepw_widgets + + +function do_changepw() +{ + global $daemon_host, $daemon_port; + + if (!isset($_SERVER['HTTPS'])) + { + $href = "https://${_SERVER['SERVER_NAME']}${_SERVER['REQUEST_URI']}"; + print "

You need a secure connection.

\n"; + print "

Try here.

\n"; + return; + } // if + + if (!is_logged_in($u, $p, $q)) + { + do_login('changepw'); + return; + } // if + + if ( (!isset($_REQUEST['pass1'])) || (!isset($_REQUEST['pass2'])) ) + output_changepw_widgets(); + else + { + $pass1 = trim($_REQUEST['pass1']); + $pass2 = trim($_REQUEST['pass2']); + $err = false; + if ( ($pass1 == '') || ($pass2 == '') ) + $err = "Please enter all fields."; + else if ($pass1 != $pass2) + $err = "Passwords do not match."; + else + { + $err = news_login($sock, $daemon_host, $daemon_port, $u, $p); + if (!$err) + { + $err = news_changepassword($sock, $pass1); + news_logout($sock); + } // if + } // else + + if (!$err) + { + echo "
\n"; + echo "Your password is changed.
\n"; + echo "Now we're forcing a logout so you can test the new password...
\n"; + echo "

\n"; + do_logout(); + } // if + + else + { + echo "

\n"; + echo "ERROR: $err
\n"; + echo "

\n"; + output_changepw_widgets(); + } // else + } // else +} // do_changepw + + function output_queue_rows($sock, $showall = 0) { // create some local variables. @@ -348,6 +462,8 @@ function output_news_queue_widgets($showall = 0) [ $showalltext | + Change password + | Log out ] @@ -1256,6 +1372,10 @@ function check_forgot_fields() that it's really you. An email will be sent to that address with a randomly-generated password so you can log in again.

+ Once you are logged in, you can + change your password + to whatever you like. +

If you are no longer have access to that email address or you can't remember what address you used, you'll have to email $newsmaster_name and @@ -1508,6 +1628,8 @@ function body_attributes($action) print('onLoad="newuserfocus();"'); else if (strcmp($action, 'forgotpw') == 0) print('onLoad="forgotfocus();"'); + else if (strcmp($action, 'changepw') == 0) + print('onLoad="changepwfocus();"'); } // body_attributes // mainline/setup.