From 497d62ab9ff68b82518f366f8fe8e26268c84db5 Mon Sep 17 00:00:00 2001 From: Alexander Davis Date: Mon, 10 Aug 2020 22:52:31 +0100 Subject: [PATCH 1/3] Possible login fix (#72) Change checks to empty() and movement of try statements --- app/public/actions/login.php | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/app/public/actions/login.php b/app/public/actions/login.php index bdfe7fe..c557f78 100644 --- a/app/public/actions/login.php +++ b/app/public/actions/login.php @@ -21,26 +21,11 @@ $user_exist_sql = $db->prepare("SELECT uuid FROM users WHERE uuid=:uuid"); $user_exist_sql->bindParam(':uuid', $oidc_user['sub']); $user_exist_sql->execute(); - $result = $user_exist_sql->setFetchMode(PDO::FETCH_ASSOC); // If user doesn't exist, $result will be null } catch (PDOException $e) { $alert = array("danger", "Error during check for user record: " . $e->getMessage()); } - if ($result != null) { - // User already exists - try { - $stmt = "UPDATE users SET uid=:username, given_name=:given, family_name=:family, email=:email WHERE uuid=:sub"; - $sql = $db->prepare($stmt); - $sql->bindParam(':sub', $oidc_user['sub']); - $sql->bindParam(':username', $oidc_user['username']); - $sql->bindParam(':given', $oidc_user['given_name']); - $sql->bindParam(':family', $oidc_user['family_name']); - $sql->bindParam(':email', $oidc_user['email']); - $sql->execute(); - } catch (PDOException $e) { - $alert = array("danger", "Error during existing user record update: " . $e->getMessage()); - } - } else { + if empty($user_exist_sql) { // User doesn't already exist try { $stmt = "INSERT INTO users (uuid, uid, given_name, family_name, email) VALUES (:sub, :username, :given, :family, :email)"; @@ -51,9 +36,23 @@ $sql->bindParam(':family', $oidc_user['family_name']); $sql->bindParam(':email', $oidc_user['email']); $sql->execute(); - } catch (PDOException $e) { + } catch (Jumbojett\PDOException $e) { $alert = array("danger", "Error during creation of new user record: " . $e->getMessage()); } + } else { + // User already exists + try { + $stmt = "UPDATE users SET uid=:username, given_name=:given, family_name=:family, email=:email WHERE uuid=:sub"; + $sql = $db->prepare($stmt); + $sql->bindParam(':sub', $oidc_user['sub']); + $sql->bindParam(':username', $oidc_user['username']); + $sql->bindParam(':given', $oidc_user['given_name']); + $sql->bindParam(':family', $oidc_user['family_name']); + $sql->bindParam(':email', $oidc_user['email']); + $sql->execute(); + } catch (Jumbojett\PDOException $e) { + $alert = array("danger", "Error during existing user record update: " . $e->getMessage()); + } } oidc_set_vars($oidc_user['sub'], $oidc_user['username'], $oidc_user['given_name'], $oidc_user['family_name'], $oidc_user['email']); -- 2.49.1 From dcc82eb424c4966ecfa621cc2fc1cac8001a40af Mon Sep 17 00:00:00 2001 From: Alexander Davis Date: Mon, 10 Aug 2020 22:58:20 +0100 Subject: [PATCH 2/3] Adding statement brackets (#73) --- app/public/actions/login.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/public/actions/login.php b/app/public/actions/login.php index c557f78..0598f9d 100644 --- a/app/public/actions/login.php +++ b/app/public/actions/login.php @@ -25,7 +25,7 @@ $alert = array("danger", "Error during check for user record: " . $e->getMessage()); } - if empty($user_exist_sql) { + if (empty($user_exist_sql)) { // User doesn't already exist try { $stmt = "INSERT INTO users (uuid, uid, given_name, family_name, email) VALUES (:sub, :username, :given, :family, :email)"; -- 2.49.1 From 49c68488121d333e82a2a4945fdb5e225092e644 Mon Sep 17 00:00:00 2001 From: Alexander Davis Date: Tue, 11 Aug 2020 12:31:03 +0100 Subject: [PATCH 3/3] Roadmap #1 (#74) --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 7ffdb8e..9997779 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,7 @@ # FHeD The Free HelpDesk is the one-stop shop for all of your IT-related needs. It is a barebones helpdesk system aimed at individuals and small businesses. + +# Roadmap +- [x] ~~Create framework.~~ +- [x] ~~Create database creation on install script.~~ -- 2.49.1