From 827be406469a4139ccd42a556bab655a170b84d6 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Wed, 25 Jan 2017 12:02:31 +0100 Subject: [PATCH 1/5] Email confirm on settings page and emailconfirm fix (: --- website/queries/emailconfirm.php | 7 +++---- website/queries/settings.php | 10 +++++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/website/queries/emailconfirm.php b/website/queries/emailconfirm.php index 583a47b..0b3224f 100644 --- a/website/queries/emailconfirm.php +++ b/website/queries/emailconfirm.php @@ -25,7 +25,9 @@ function sendConfirmEmail(int $userID) { WHERE `userID` = :userID "); + $stmt->bindParam(":userID", $userID); + $stmt->execute(); $user = $stmt->fetch(); $email = $user["email"]; @@ -34,10 +36,7 @@ function sendConfirmEmail(int $userID) { $confirmLink = "https://myhyvesbookplus.nl/emailconfirm.php?u=$userID&h=$hash"; $subject = "Bevestig uw emailadres"; - $body = "Hallo $fname,\r\n\r\n - Klik op de onderstaande link om uw emailadres te bevestigen.\r\n\r\n - $confirmLink\r\n\r\n - Groeten MyHyvesbook+"; + $body = "Hallo $fname,\r\n\r\nKlik op de onderstaande link om uw emailadres te bevestigen.\r\n\r\n$confirmLink\r\n\r\nGroeten MyHyvesbook+"; $header = "From: MyHyvesbook+ "; mail($email, $subject, $body, $header); } \ No newline at end of file diff --git a/website/queries/settings.php b/website/queries/settings.php index d3985c7..0bf8791 100644 --- a/website/queries/settings.php +++ b/website/queries/settings.php @@ -1,4 +1,6 @@ bindParam(":email", $email); $stmt->bindParam(":userID", $_SESSION["userID"]); $stmt->execute(); -// return $stmt->rowCount(); if ($stmt->rowCount()) { + sendConfirmEmail($_SESSION["userID"]); + session_destroy(); throw new HappyAlert("Emailadres is veranderd."); } else { throw new AngryAlert(); From 185874d23f216ee8e1d0dd485fbfec488715e861 Mon Sep 17 00:00:00 2001 From: Marijn Jansen Date: Wed, 25 Jan 2017 12:06:13 +0100 Subject: [PATCH 2/5] Cleanup at logout.php --- website/public/logout.php | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/website/public/logout.php b/website/public/logout.php index 6a2ba5d..de4d7c2 100644 --- a/website/public/logout.php +++ b/website/public/logout.php @@ -1,15 +1,4 @@ - - - - - - +session_start(); +session_destroy(); +header("Location: login.php"); \ No newline at end of file From aa48092d2786b0ffc56aaa17a444c83b4723fe6e Mon Sep 17 00:00:00 2001 From: Joey Lai Date: Wed, 25 Jan 2017 12:48:30 +0100 Subject: [PATCH 3/5] Added confirmation login email --- website/public/js/registerAndLogin.js | 7 +++++++ website/public/login.php | 3 ++- website/public/register.php | 2 ++ website/queries/login.php | 4 ++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/website/public/js/registerAndLogin.js b/website/public/js/registerAndLogin.js index 4e68a07..92d2281 100644 --- a/website/public/js/registerAndLogin.js +++ b/website/public/js/registerAndLogin.js @@ -8,4 +8,11 @@ function checkLoggedIn() { function bannedAlert(){ alert("Your account is banned"); +} + +function emailNotConfirmed(userID){ + if (confirm("Your email is not confirmed.\nPress ok to send another confirmation.") == true) { + sendConfirmEmail(userID); + } + } \ No newline at end of file diff --git a/website/public/login.php b/website/public/login.php index b3a00b0..de4ecab 100644 --- a/website/public/login.php +++ b/website/public/login.php @@ -5,6 +5,7 @@ require_once("../queries/connect.php"); include_once("../queries/login.php"); include_once("../queries/checkInput.php"); + include_once("../queries/emailconfirm.php"); ?> getMessage(); diff --git a/website/public/register.php b/website/public/register.php index 84d6873..1ce4817 100644 --- a/website/public/register.php +++ b/website/public/register.php @@ -5,6 +5,7 @@ require_once("../queries/connect.php"); include_once("../queries/register.php"); include_once("../queries/checkInput.php"); + include_once("../queries/emailconfirm.php"); ?> getMessage(); } diff --git a/website/queries/login.php b/website/queries/login.php index 8605e67..2955942 100644 --- a/website/queries/login.php +++ b/website/queries/login.php @@ -34,6 +34,10 @@ function validateLogin($username, $password){ echo ""; + } else if ($role == "unconfirmed"){ + echo ""; } else { $_SESSION["userID"] = $userID; header("location: profile.php"); From 30d1ef40f4ed4c2c91510d76044a74e89930875e Mon Sep 17 00:00:00 2001 From: Joey Lai Date: Wed, 25 Jan 2017 12:55:29 +0100 Subject: [PATCH 4/5] fixed js for login --- website/public/js/registerAndLogin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/public/js/registerAndLogin.js b/website/public/js/registerAndLogin.js index 92d2281..87351bf 100644 --- a/website/public/js/registerAndLogin.js +++ b/website/public/js/registerAndLogin.js @@ -13,6 +13,6 @@ function bannedAlert(){ function emailNotConfirmed(userID){ if (confirm("Your email is not confirmed.\nPress ok to send another confirmation.") == true) { sendConfirmEmail(userID); - } + } } \ No newline at end of file From e840def73387ee904cee0f30a27646bff10e2840 Mon Sep 17 00:00:00 2001 From: Joey Lai Date: Wed, 25 Jan 2017 13:43:08 +0100 Subject: [PATCH 5/5] FIxed confirmation login --- website/public/js/registerAndLogin.js | 7 ++----- website/queries/login.php | 6 ++++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/website/public/js/registerAndLogin.js b/website/public/js/registerAndLogin.js index 87351bf..ef49e83 100644 --- a/website/public/js/registerAndLogin.js +++ b/website/public/js/registerAndLogin.js @@ -10,9 +10,6 @@ function bannedAlert(){ alert("Your account is banned"); } -function emailNotConfirmed(userID){ - if (confirm("Your email is not confirmed.\nPress ok to send another confirmation.") == true) { - sendConfirmEmail(userID); - } - +function emailNotConfirmed(){ + alert("Your account has not been verified yet!\nAnother email has been sent to you") } \ No newline at end of file diff --git a/website/queries/login.php b/website/queries/login.php index 2955942..2af255a 100644 --- a/website/queries/login.php +++ b/website/queries/login.php @@ -35,8 +35,9 @@ function validateLogin($username, $password){ window.onload=bannedAlert(); "; } else if ($role == "unconfirmed"){ + sendConfirmEmail(getUser()["userID"]); echo ""; } else { $_SESSION["userID"] = $userID; @@ -56,4 +57,5 @@ class loginException extends Exception parent::__construct($message, $code, $previous); } } -?> \ No newline at end of file +?> +