diff --git a/account.php b/account.php index 18231ab48938671748b561d05611239e27fe86f5..416cd4761dda9d5b9f851dd40b58a8877bf7c598 100644 --- a/account.php +++ b/account.php @@ -52,7 +52,6 @@ if ($user && $_POST) { if (!$errors && $user->updateInfo($_POST, $errors)) Http::redirect('tickets.php'); } - elseif ($_POST) { $user_form = UserForm::getUserForm()->getForm($_POST); if ($thisclient) { @@ -81,12 +80,12 @@ elseif ($_POST) { $errors['email'] = sprintf(__('%s is a required field'), $user_form->getField('email')->getLocal('label')); elseif (!$user_form->getField('name')->getClean()) $errors['name'] = sprintf(__('%s is a required field'), $user_form->getField('name')->getLocal('label')); + // Registration for existing users + elseif ($addr && !($user = User::lookupByEmail($addr))) + $errors['err'] = __('Unable to register account. See messages below'); // Users created from ClientCreateRequest elseif (isset($_POST['backend']) && !($user = User::fromVars($user_form->getClean()))) $errors['err'] = __('Unable to create local account. See messages below'); - // Registration for existing users - elseif (!$user && !$thisclient && !($user = User::fromVars($user_form->getClean()))) - $errors['err'] = __('Unable to register account. See messages below'); // New users and users registering from a ticket access link elseif (!$user && !($user = $thisclient ?: User::fromForm($user_form))) $errors['err'] = __('Unable to register account. See messages below'); diff --git a/include/class.user.php b/include/class.user.php index 083e0d5bf2b1853e82d6804a53641d353dbf8fd9..71a5289a83a14540662aa159f391c6423b7ec359 100644 --- a/include/class.user.php +++ b/include/class.user.php @@ -1147,16 +1147,10 @@ class UserAccount extends VerySimpleModel { } /* - * This assumes the staff is doing the update + * Updates may be done by Staff or by the User if registration + * options are set to Public */ function update($vars, &$errors) { - global $thisstaff; - - - if (!$thisstaff) { - $errors['err'] = __('Access denied'); - return false; - } // TODO: Make sure the username is unique