Merge branch 'joey-testing' into 'master'
Added fbModal button See merge request !208
This commit was merged in pull request #212.
This commit is contained in:
@@ -7,7 +7,7 @@ var facebookModal = document.getElementById("fbModal");
|
|||||||
// Get the button that opens the modal
|
// Get the button that opens the modal
|
||||||
var registerBtn = document.getElementById("registerBtn");
|
var registerBtn = document.getElementById("registerBtn");
|
||||||
var btn = document.getElementById("myBtn");
|
var btn = document.getElementById("myBtn");
|
||||||
|
var fbBtn = document.getElementById("fbBtn");
|
||||||
|
|
||||||
// Get the <span> element that closes the modal
|
// Get the <span> element that closes the modal
|
||||||
var span = document.getElementsByClassName("close")[0];
|
var span = document.getElementsByClassName("close")[0];
|
||||||
@@ -24,6 +24,9 @@ btn.onclick = function () {
|
|||||||
registerBtn.onclick = function () {
|
registerBtn.onclick = function () {
|
||||||
registerModal.style.display = "block";
|
registerModal.style.display = "block";
|
||||||
}
|
}
|
||||||
|
fbBtn.onclick = function () {
|
||||||
|
facebookModal.style.display = "block";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WHen the user clicks on (X), close the modal
|
* WHen the user clicks on (X), close the modal
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 1 if an username exists with the filled in username.
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
function getExistingUsername() {
|
function getExistingUsername() {
|
||||||
$stmt = prepareQuery("
|
$stmt = prepareQuery("
|
||||||
SELECT
|
SELECT
|
||||||
@@ -16,6 +20,10 @@ function getExistingUsername() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 1 if an username exists with facebooklogin
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
function getExistingFBUsername() {
|
function getExistingFBUsername() {
|
||||||
$stmt = prepareQuery("
|
$stmt = prepareQuery("
|
||||||
SELECT
|
SELECT
|
||||||
@@ -32,6 +40,10 @@ function getExistingFBUsername() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 1 if an email exists with the filled in email.
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
function getExistingEmail() {
|
function getExistingEmail() {
|
||||||
$stmt = prepareQuery("
|
$stmt = prepareQuery("
|
||||||
SELECT
|
SELECT
|
||||||
@@ -48,6 +60,10 @@ function getExistingEmail() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 1 if an email exists with facebook register
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
function getExistingFBEmail() {
|
function getExistingFBEmail() {
|
||||||
$stmt = prepareQuery("
|
$stmt = prepareQuery("
|
||||||
SELECT
|
SELECT
|
||||||
@@ -65,6 +81,10 @@ function getExistingFBEmail() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 1 if an email exists with the forgot email input
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
function getResetEmail() {
|
function getResetEmail() {
|
||||||
$stmt = prepareQuery("
|
$stmt = prepareQuery("
|
||||||
SELECT
|
SELECT
|
||||||
@@ -81,6 +101,9 @@ function getResetEmail() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a new account in the database
|
||||||
|
*/
|
||||||
function registerAccount() {
|
function registerAccount() {
|
||||||
$stmt = prepareQuery("
|
$stmt = prepareQuery("
|
||||||
INSERT INTO
|
INSERT INTO
|
||||||
@@ -119,6 +142,9 @@ function registerAccount() {
|
|||||||
$stmt->rowCount();
|
$stmt->rowCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a new account with facebook register
|
||||||
|
*/
|
||||||
function fbRegisterAccount() {
|
function fbRegisterAccount() {
|
||||||
$stmt = prepareQuery("
|
$stmt = prepareQuery("
|
||||||
INSERT INTO
|
INSERT INTO
|
||||||
@@ -158,6 +184,11 @@ function fbRegisterAccount() {
|
|||||||
return $stmt->execute();
|
return $stmt->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks which dates need to be selected when there is an invalid registration.
|
||||||
|
* @param $date
|
||||||
|
* @param $value
|
||||||
|
*/
|
||||||
function submitselect($date, $value){
|
function submitselect($date, $value){
|
||||||
if ($date == $value){
|
if ($date == $value){
|
||||||
echo "selected";
|
echo "selected";
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
include_once "../queries/connect.php";
|
include_once "../queries/connect.php";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a link to an email to change the password of an account
|
||||||
|
* @param string $email
|
||||||
|
*/
|
||||||
function sendPasswordRecovery(string $email) {
|
function sendPasswordRecovery(string $email) {
|
||||||
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||||
$stmt = prepareQuery("
|
$stmt = prepareQuery("
|
||||||
@@ -24,11 +28,16 @@ function sendPasswordRecovery(string $email) {
|
|||||||
$hashedHash = password_hash($hash, PASSWORD_DEFAULT);
|
$hashedHash = password_hash($hash, PASSWORD_DEFAULT);
|
||||||
setHashToDatabase($userID, $hash);
|
setHashToDatabase($userID, $hash);
|
||||||
doSendPasswordRecovery($userID, $email, $username, $hashedHash);
|
doSendPasswordRecovery($userID, $email, $username, $hashedHash);
|
||||||
} else {
|
|
||||||
// TODO: Be angry!
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the message in the email to reset a password of an account.
|
||||||
|
* @param int $userID
|
||||||
|
* @param string $email
|
||||||
|
* @param string $username
|
||||||
|
* @param string $hash
|
||||||
|
*/
|
||||||
function doSendPasswordRecovery(int $userID, string $email, string $username, string $hash) {
|
function doSendPasswordRecovery(int $userID, string $email, string $username, string $hash) {
|
||||||
$resetLink = "https://myhyvesbookplus.nl/resetpassword.php?u=$userID&h=$hash";
|
$resetLink = "https://myhyvesbookplus.nl/resetpassword.php?u=$userID&h=$hash";
|
||||||
|
|
||||||
@@ -38,6 +47,11 @@ function doSendPasswordRecovery(int $userID, string $email, string $username, st
|
|||||||
mail($email, $subject, $body, $header);
|
mail($email, $subject, $body, $header);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the previous password invalid.
|
||||||
|
* @param int $userID
|
||||||
|
* @param string $hash
|
||||||
|
*/
|
||||||
function setHashToDatabase(int $userID, string $hash) {
|
function setHashToDatabase(int $userID, string $hash) {
|
||||||
$stmt = prepareQuery("
|
$stmt = prepareQuery("
|
||||||
UPDATE
|
UPDATE
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
if(isset($acces_token)) {
|
||||||
|
echo '<button id="fbBtn" class="button">Facebook registreer</button>';
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
||||||
<!-- The Modal -->
|
<!-- The Modal -->
|
||||||
<div id="fbModal" class="modal">
|
<div id="fbModal" class="modal">
|
||||||
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
|
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
|
||||||
|
|||||||
Reference in New Issue
Block a user