From 21b8dfee87185fc83e66ce2b33596fecba2d773c Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Fri, 18 Apr 2014 15:11:43 -0500 Subject: [PATCH] oops: Fixup registration for existing users --- account.php | 10 +++++++--- include/class.client.php | 2 +- include/class.user.php | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/account.php b/account.php index 9d1dbcc98..657f09831 100644 --- a/account.php +++ b/account.php @@ -53,11 +53,12 @@ if ($user && $_POST) { elseif ($_POST) { $user_form = UserForm::getUserForm()->getForm($_POST); - $user_form->getField('email')->configure('disabled', true); - if ($thisclient) + if ($thisclient) { + $user_form->getField('email')->configure('disabled', true); $user_form->getField('email')->value = $thisclient->getEmail(); + } - if (!$user_form->isValid(function($f) { return !$f->get('internal'); })) + if (!$user_form->isValid(function($f) { return !$f->get('private'); })) $errors['err'] = 'Incomplete client information'; elseif (!$_POST['backend'] && !$_POST['passwd1']) $errors['passwd1'] = 'New password required'; @@ -76,6 +77,9 @@ elseif ($_POST) { // 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.client.php b/include/class.client.php index e8a30dd22..4badbc789 100644 --- a/include/class.client.php +++ b/include/class.client.php @@ -360,7 +360,7 @@ class ClientAccount extends UserAccount { $info = array('password' => $vars['passwd1']); Signal::send('auth.pwchange', $this, $info); $this->cancelResetTokens(); - $this->clearStatus(self::REQUIRE_PASSWD_RESET); + $this->clearStatus(UserAccountStatus::REQUIRE_PASSWD_RESET); } return $this->save(); diff --git a/include/class.user.php b/include/class.user.php index ac544e8f4..37137177d 100644 --- a/include/class.user.php +++ b/include/class.user.php @@ -702,7 +702,7 @@ class UserAccount extends UserAccountModel { $vars['reset_link'] = &$vars['link']; $info = array('email' => $email, 'vars' => &$vars, 'log'=>true); - Signal::send('auth.pwreset.email', $this, $info); + Signal::send('auth.pwreset.email', $this->getUser(), $info); $msg = $ost->replaceTemplateVariables(array( 'subj' => $content->getName(), -- GitLab