summaryrefslogtreecommitdiff
path: root/web/html
diff options
context:
space:
mode:
authorMarcel Korpel <marcel.korpel@gmail.com>2015-07-19 22:32:06 +0200
committerLukas Fleischer <lfleischer@archlinux.org>2015-08-08 12:59:24 +0200
commit8db2ff5da679b3c2d5a53f67f67863d786057f36 (patch)
tree3e226df9c508847e4044336e7c506c3e9ac8a250 /web/html
parentcb9c0d2477480b63294854ce2abf7d9a34059ee6 (diff)
Set correct 'My Account' link after changing username
Don't print messages (and the account form) in process_account_form() anymore, but return them to the caller. When updating accounts, this function will be called before the headers are written. If a username has been changed by process_account_form(), the headers now show the updated username from the database in the 'My Account' link. Clicking on it immediately after changing a username will no longer lead to a non-existing URL. Signed-off-by: Marcel Korpel <marcel.korpel@gmail.com> Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'web/html')
-rw-r--r--web/html/account.php38
-rw-r--r--web/html/register.php11
2 files changed, 38 insertions, 11 deletions
diff --git a/web/html/account.php b/web/html/account.php
index f5e6c19..adc2542 100644
--- a/web/html/account.php
+++ b/web/html/account.php
@@ -19,6 +19,26 @@ if (in_array($action, $need_userinfo)) {
$PK = implode("\n", account_get_ssh_keys($row["ID"]));
}
+/* This has to be done before the navigation headers are written,
+ * because html_header() fetches the current username from the database,
+ * which could be changed by process_account_form()
+ */
+if ($action == "UpdateAccount") {
+ $update_account_message = '';
+ /* Details for account being updated */
+ /* Verify user permissions and that the request is a valid POST */
+ if (can_edit_account($row) && check_token()) {
+ /* Update the details for the existing account */
+ list($success, $update_account_message) = process_account_form(
+ "edit", "UpdateAccount",
+ in_request("U"), in_request("T"), in_request("S"),
+ in_request("E"), in_request("P"), in_request("C"),
+ in_request("R"), in_request("L"), in_request("I"),
+ in_request("K"), in_request("PK"), in_request("J"),
+ in_request("ID"), $row["Username"]);
+ }
+}
+
if ($action == "AccountInfo") {
html_header(__('Account') . ' ' . $row['Username']);
} else {
@@ -91,17 +111,15 @@ if (isset($_COOKIE["AURSID"])) {
}
} elseif ($action == "UpdateAccount") {
- /* Details for account being updated */
- /* Verify user permissions and that the request is a valid POST */
- if (can_edit_account($row) && check_token()) {
- /* Update the details for the existing account */
- process_account_form("edit", "UpdateAccount",
- in_request("U"), in_request("T"), in_request("S"),
- in_request("E"), in_request("P"), in_request("C"),
- in_request("R"), in_request("L"), in_request("I"),
- in_request("K"), in_request("PK"), in_request("J"),
- in_request("ID"), $row["Username"]);
+ print $update_account_message;
+
+ if (!$success) {
+ display_account_form("UpdateAccount", in_request("U"), in_request("T"),
+ in_request("S"), in_request("E"), in_request("P"), in_request("C"),
+ in_request("R"), in_request("L"), in_request("I"), in_request("K"),
+ in_request("PK"), in_request("J"), in_request("ID"), $row["Username"]);
}
+
} else {
if (has_credential(CRED_ACCOUNT_SEARCH)) {
# display the search page if they're a TU/dev
diff --git a/web/html/register.php b/web/html/register.php
index cb3e8dd..9c5c1cc 100644
--- a/web/html/register.php
+++ b/web/html/register.php
@@ -19,11 +19,20 @@ echo '<div class="box">';
echo '<h2>' . __('Register') . '</h2>';
if (in_request("Action") == "NewAccount") {
- process_account_form("new", "NewAccount", in_request("U"), 1, 0,
+ list($success, $message) = process_account_form(
+ "new", "NewAccount", in_request("U"), 1, 0,
in_request("E"), '', '', in_request("R"),
in_request("L"), in_request("I"), in_request("K"),
in_request("PK"));
+ print $message;
+
+ if (!$success) {
+ display_account_form("NewAccount", in_request("U"), 1, 0,
+ in_request("E"), '', '', in_request("R"),
+ in_request("L"), in_request("I"), in_request("K"),
+ in_request("PK"));
+ }
} else {
print '<p>' . __("Use this form to create an account.") . '</p>';
display_account_form("NewAccount", "", "", "", "", "", "", "", $LANG);