From 8f73293955194fe6980764b9a96a817918686c8b Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Fri, 25 Apr 2014 09:47:44 -0500
Subject: [PATCH] Permit clients originally from ext auth to set a passwd

If a client initially authenticates with an external source such as Google+,
the user should still have the ability to set a password via the password
reset mechanism.
---
 include/class.user.php | 3 +--
 pwreset.php            | 9 ++++-----
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/include/class.user.php b/include/class.user.php
index 17408aa33..45f84afc1 100644
--- a/include/class.user.php
+++ b/include/class.user.php
@@ -775,8 +775,7 @@ class UserAccountModel extends VerySimpleModel {
     }
 
     function isPasswdResetEnabled() {
-        return !$this->hasStatus(UserAccountStatus::FORBID_PASSWD_RESET)
-            && (!$this->backend || $this->backend == 'client');
+        return !$this->hasStatus(UserAccountStatus::FORBID_PASSWD_RESET);
     }
 
     function getStatus() {
diff --git a/pwreset.php b/pwreset.php
index 3680cdf3e..2b63aabf6 100644
--- a/pwreset.php
+++ b/pwreset.php
@@ -16,16 +16,15 @@ if($_POST) {
     switch ($_POST['do']) {
         case 'sendmail':
             if (($acct=ClientAccount::lookupByUsername($_POST['userid']))) {
-                if (!$acct->hasPassword()) {
-                    $banner = 'Unable to reset password. Contact your administrator';
-                }
-                elseif (!$acct->isPasswdResetEnabled()) {
+                if (!$acct->isPasswdResetEnabled()) {
                     $banner = 'Password reset is not enabled for your account. '
                         .'Contact your administrator';
                 }
-                elseif (!$acct->sendResetEmail()) {
+                elseif ($acct->sendResetEmail()) {
                     $inc = 'pwreset.sent.php';
                 }
+                else
+                    $banner = 'Unable to send reset email. Internal error';
             }
             else
                 $banner = 'Unable to verify username '
-- 
GitLab