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:
Lars van Hijfte
2017-02-03 21:20:25 +01:00
4 changed files with 57 additions and 3 deletions

View File

@@ -7,7 +7,7 @@ var facebookModal = document.getElementById("fbModal");
// Get the button that opens the modal
var registerBtn = document.getElementById("registerBtn");
var btn = document.getElementById("myBtn");
var fbBtn = document.getElementById("fbBtn");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
@@ -24,6 +24,9 @@ btn.onclick = function () {
registerBtn.onclick = function () {
registerModal.style.display = "block";
}
fbBtn.onclick = function () {
facebookModal.style.display = "block";
}
/**
* WHen the user clicks on (X), close the modal

View File

@@ -1,5 +1,9 @@
<?php
/**
* Returns 1 if an username exists with the filled in username.
* @return int
*/
function getExistingUsername() {
$stmt = prepareQuery("
SELECT
@@ -16,6 +20,10 @@ function getExistingUsername() {
}
/**
* Returns 1 if an username exists with facebooklogin
* @return int
*/
function getExistingFBUsername() {
$stmt = prepareQuery("
SELECT
@@ -32,6 +40,10 @@ function getExistingFBUsername() {
}
/**
* Returns 1 if an email exists with the filled in email.
* @return int
*/
function getExistingEmail() {
$stmt = prepareQuery("
SELECT
@@ -48,6 +60,10 @@ function getExistingEmail() {
}
/**
* Returns 1 if an email exists with facebook register
* @return int
*/
function getExistingFBEmail() {
$stmt = prepareQuery("
SELECT
@@ -65,6 +81,10 @@ function getExistingFBEmail() {
}
/**
* Returns 1 if an email exists with the forgot email input
* @return int
*/
function getResetEmail() {
$stmt = prepareQuery("
SELECT
@@ -81,6 +101,9 @@ function getResetEmail() {
}
/**
* Registers a new account in the database
*/
function registerAccount() {
$stmt = prepareQuery("
INSERT INTO
@@ -119,6 +142,9 @@ function registerAccount() {
$stmt->rowCount();
}
/**
* Registers a new account with facebook register
*/
function fbRegisterAccount() {
$stmt = prepareQuery("
INSERT INTO
@@ -158,6 +184,11 @@ function fbRegisterAccount() {
return $stmt->execute();
}
/**
* Checks which dates need to be selected when there is an invalid registration.
* @param $date
* @param $value
*/
function submitselect($date, $value){
if ($date == $value){
echo "selected";

View File

@@ -1,6 +1,10 @@
<?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) {
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
$stmt = prepareQuery("
@@ -24,11 +28,16 @@ function sendPasswordRecovery(string $email) {
$hashedHash = password_hash($hash, PASSWORD_DEFAULT);
setHashToDatabase($userID, $hash);
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) {
$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);
}
/**
* Sets the previous password invalid.
* @param int $userID
* @param string $hash
*/
function setHashToDatabase(int $userID, string $hash) {
$stmt = prepareQuery("
UPDATE

View File

@@ -1,3 +1,9 @@
<?php
if(isset($acces_token)) {
echo '<button id="fbBtn" class="button">Facebook registreer</button>';
}
?>
<!-- The Modal -->
<div id="fbModal" class="modal">
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"