Rollback Fix

This commit is contained in:
Minik Gaarde Lambrecht 2021-03-26 10:24:47 +01:00
parent 42159a3eb7
commit bb61351df5
8 changed files with 154 additions and 220 deletions

View File

@ -8,12 +8,3 @@ function isAdmin(): bool
return isset($_SESSION['admin']); return isset($_SESSION['admin']);
} }
function makeAdminLogin(string $userName)
{
setcookie("userName", $userName, [
'expires' => 0,
'samesite' => 'Strict',
'path' => '/'
]);
}

View File

@ -19,7 +19,6 @@ if(isset($_POST['aLogin'])){
$_SESSION['userName'] = $userName; $_SESSION['userName'] = $userName;
$_SESSION['admin'] = true; $_SESSION['admin'] = true;
$_SESSION['success'] = "You are now logged in"; $_SESSION['success'] = "You are now logged in";
makeAdminLogin($userName);
http_response_code(200); http_response_code(200);
}else{ }else{
session_destroy(); session_destroy();

View File

@ -1,9 +1,8 @@
<?php <?php
session_start(); session_start();
session_unset();
session_destroy();
session_destroy();
$cookieCon = array( $cookieCon = array(
'expires' => -1, 'expires' => -1,
@ -12,6 +11,5 @@ $cookieCon = array(
); );
setcookie("groupName", null, $cookieCon); setcookie("groupName", null, $cookieCon);
setcookie("groupId", null, $cookieCon); setcookie("groupId", null, $cookieCon);
setcookie("userName", null, $cookieCon);
echo http_response_code(200); echo http_response_code(200);

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -82,15 +82,11 @@
</a> </a>
</li> </li>
</ul> </ul>
<a id="AdminPanel" type="button" class="nav-link RightNavButton" style="display: none;"> <a id="NavLogin" type="button" class="nav-link LoginButton" data-bs-toggle="modal" data-bs-target="#LoginModal" style="display: block;">
Admin Panel
</a>
<a id="NavLogin" type="button" class="nav-link RightNavButton" data-bs-toggle="modal" data-bs-target="#LoginModal" style="display: block;">
Login Login
</a> </a>
<a id="NavUser" class="nav-link RightNavText" style="display: none;"></a> <a id="NavUser" type="button" class="nav-link LoginButton" style="display: none;">
<a id="UserLogout" type="button" class="nav-link RightNavButton" style="display: none;">
Logout
</a> </a>
</div> </div>
</div> </div>
@ -124,56 +120,67 @@
<div class="modal-body"> <div class="modal-body">
<div class="tab-content" id="ModalLoginTabContent"> <div class="tab-content" id="ModalLoginTabContent">
<div class="tab-pane fade show active" id="Login" role="tabpanel" aria-labelledby="LoginTab"> <div class="tab-pane fade show active" id="Login" role="tabpanel" aria-labelledby="LoginTab">
<form class="box"> <form id="LoginForm" class="box">
<h1 class="text-muted"> <h1 class="text-muted">
Team Login Team Login
</h1> </h1>
<input id="loginUsername" type="text" name="groupName" placeholder="Gruppe navn"> <input id="loginUsername" type="text" name="groupName" placeholder="Gruppe navn">
<input id="loginPassword" type="password" name="password" placeholder="Password"> <input id="loginPassword" type="password" name="password" placeholder="Password">
<input id="LoginBtn" type="submit" name="login" value="Login"> <input id="LoginBtn" type="submit" name="login" value="Login">
<input id="AdminLoginBtn" type="submit" name="aLogin" value="Login som admin">
</form> </form>
</div> </div>
<div class="tab-pane fade" id="Registrer" role="tabpanel" aria-labelledby="RegistrerTab"> <div class="tab-pane fade" id="Registrer" role="tabpanel" aria-labelledby="RegistrerTab">
<form class="box"> <form id="RegisterForm" method="POST" class="box">
<h1 class="text-muted"> <h1 class="text-muted">
Team Registrering Team Registrering
</h1> </h1>
<input id="username" type="text" name="" placeholder="Gruppe navn"> <input id="username" type="text" name="groupName" placeholder="Unikt gruppe navn">
<input id="pass1" type="password" class="" name="" placeholder="Password"> <input id="pass1" type="password" class="" placeholder="Password">
<input id="pass2" type="password" name="" placeholder="Gentag Password"> <input id="pass2" type="password" class="" name="password" placeholder="Gentag Password">
<div class="form-check" style="display: table; margin: auto;"> <select id="GameJamSelect" class="form-select" aria-label="Default select example">
<input class="form-check-input" type="checkbox" value="" id="flexCheckDefault">
<label class="form-check-label" for="flexCheckDefault"> </select>
Jeg accepterer Vilkår og betingelser
</label> <input type="hidden" name="groupAmount" id="groupAmount">
<input type="hidden" name="gameJamId" id="gameJamId">
<div id="NUD" class="btn-group" role="group" aria-label="Basic example">
<button id="NUDMinus" type="button" class="btn btn-primary">
<i class="fas fa-minus"></i>
</button>
<button disabled id="NUDDisplay" type="button" class="btn btn-primary">
Antal medlemmer
</button>
<button id="NUDPlus" type="button" class="btn btn-primary">
<i class="fas fa-plus"></i>
</button>
</div> </div>
<div id="pass_info"> <div id="pass_info">
<h5>Passsword skal opfylde følgende krav :</h5> <h5>Passsword skal opfylde følgende krav :</h5>
<ul> <ul>
<li id="letter" class="invalid"> <li id="letter" class="invalid">
Mindst 1 <strong>bogstave Mindst 1 <strong>lille bogstave</strong>
</strong>
</li> </li>
<li id="capital" class="invalid"> <li id="capital" class="invalid">
Mindst 1 <strong>stort bogstave Mindst 1 <strong>stort bogstave</strong>
</strong>
</li> </li>
<li id="number" class="invalid"> <li id="number" class="invalid">
Mindst 1 <strong>tal Mindst 1 <strong>tal</strong>
</strong>
</li> </li>
<li id="length" class="invalid"> <li id="special" class="invalid">
Mindst <strong>8 tegn langt Mindst 1 <strong>special tegn</strong>
</strong> </li>
<li id="min-length" class="invalid">
Mindst <strong>8 tegn langt</strong>
</li>
<li id="max-length" class="invalid">
Maksimalt <strong>255 tegn langt</strong>
</li> </li>
</ul> </ul>
</div> </div>
<input type="submit" name="" value="Registrer" href="#"> <input id="RegisterBtn" type="submit" name="regGroup" value="Registrer">
</form> </form>
</div> </div>
</div> </div>

View File

@ -1,36 +1,28 @@
$(document).ready(function () { $(document).ready(function () {
// Register Start
let selectedGameJam; let selectedGameJam;
let MemberSize = $('#NUDDisplay').text();
let displayValue = 0; let displayValue = 0;
let AvailableJams = [ let arr = [
{"id": "-1", "Gamejam": "Vælg aktivt GameJam"} {"id": "-1", "Gamejam": "Vælg aktivt GameJam"}
]; ];
let GroupName = getCookie('groupName');
let GroupId = getCookie('groupId');
// Control Logged in users
if (GroupId != null)
{
LoggedInUser();
}
//
// Register Start
// Populate select with options from the database // Populate select with options from the database
axios.get('/Backend/Controllers/GameJam/GetGameJam.php') axios.get('/Backend/Controllers/GameJam/GetGameJam.php')
.then(function(res) { .then(function(res) {
let resArr = res.data.data; let resArr = res.data;
for(let i = 0; i < resArr.length; i++) //console.log(res.data.data);
for(let i = 0; i < res.data.data.length; i++)
{ {
AvailableJams.push({ arr.push({
id: resArr[i].id, id: res.data.data[i].id,
Gamejam: resArr[i].name Gamejam: res.data.data[i].name
}); });
} }
$.each(AvailableJams, function(i, data) { $.each(arr, function(i, data) {
if (i === 0) if (i === 0)
{ {
$('#GameJamSelect').append('<option disabled selected value="' + data.id + '">' + data.Gamejam + '</option>'); $('#GameJamSelect').append('<option disabled selected value="' + data.id + '">' + data.Gamejam + '</option>');
@ -162,15 +154,7 @@ $(document).ready(function () {
axios.post(URL, formData, { axios.post(URL, formData, {
header: 'multipart/form-data' header: 'multipart/form-data'
}).then(res => { }).then(res => {
if (res.status == 201) console.log(res);
{
let LoginModalElem = document.getElementById('LoginModal')
let LoginModal = bootstrap.Modal.getInstance(LoginModalElem);
LoginModal.hide();
LoggedInUser();
}
}).catch(error => { }).catch(error => {
console.log(error); console.log(error);
}); });
@ -205,14 +189,20 @@ $(document).ready(function () {
$('#NUDDisplay').text(displayValue); $('#NUDDisplay').text(displayValue);
} }
}); });
async function GetGroupNames() {
const res = await axios.get('/Backend/Controllers/Group/GetGroup.php');
return res.data;
}
// Register end // Register end
// Login start // Login start
$('#LoginForm').submit(function(e) { $('#LoginForm').submit(function(e) {
let URL = "/Backend/Controllers/Group/Login.php"; let URL = "/Backend/Controllers/Group/Login.php";
$('#loginUsername').attr('name') = "groupName";
let form = $('#LoginForm')[0]; let form = $('#LoginForm')[0];
let formData = new FormData(form); let formData = new FormData(form);
@ -221,17 +211,13 @@ $(document).ready(function () {
formData.append(id, value); formData.append(id, value);
axios.post(URL, formData, { axios.post(URL, formData, {
header: 'multipart/form-data' header: 'multipart/form-data'
}).then(res => { }).then(res => {
if (res.status === 200) if (res.status === 200)
{ {
let LoginModalElem = document.getElementById('LoginModal') console.log('Logged in');
let LoginModal = bootstrap.Modal.getInstance(LoginModalElem);
LoginModal.hide();
LoggedInUser();
} }
}).catch(error => { }).catch(error => {
console.log(error); console.log(error);
@ -240,94 +226,4 @@ $(document).ready(function () {
e.preventDefault(); e.preventDefault();
}) })
// Login end // Login end
// Admin Login Start
$('#AdminLoginBtn').submit(function(e) {
let URL = "/Backend/Controllers/Admin/AdminLogin.php";
$('#loginUsername').attr('name') = "userName";
let form = $('#LoginForm')[0];
let formData = new FormData(form);
let id = $('#LoginBtn').attr('name');
let value = $('#LoginBtn').val();
formData.append(id, value);
axios.post(URL, formData, {
header: 'multipart/form-data'
}).then(res => {
if (res.status === 200)
{
let LoginModalElem = document.getElementById('LoginModal')
let LoginModal = bootstrap.Modal.getInstance(LoginModalElem);
LoginModal.hide();
LoggedInUser();
}
}).catch(error => {
console.log(error);
});
e.preventDefault();
});
// Admin Login End
// Logout Start
$('#UserLogout').click(function() {
axios.get('/Backend/Controllers/Group/Logout.php').then(res => {
if(res.status === 200)
{
UserLoggedOut();
}
}).catch(error => {
console.log(error);
});
});
// Logout End
// Functions Start
function LoggedInUser() {
$('#NavLogin').css({
"display": "none"
});
$('#UserLogout').css({
"display": "block"
});
$('#NavUser').text(`Logget ind som: ${GroupName}`);
$('#NavUser').css({
"display": "block"
});
}
function UserLoggedOut() {
$('#NavLogin').css({
"display": "block"
});
$('#UserLogout').css({
"display": "None"
});
$('#NavUser').css({
"display": "none"
});
}
async function GetGroupNames() {
const res = await axios.get('/Backend/Controllers/Group/GetGroup.php');
return res.data;
}
function getCookie(name) {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) return parts.pop().split(';').shift();
}
// Functions End
}); });

View File

@ -118,15 +118,11 @@ a:hover {
margin: 1vw 10vw 0; margin: 1vw 10vw 0;
} }
.RightNavText { .LoginButton {
color: rgba(255, 255, 255, .75);
}
.RightNavButton {
color: rgba(255, 255, 255, .55); color: rgba(255, 255, 255, .55);
} }
.RightNavButton:hover { .LoginButton:hover {
color: rgba(255, 255, 255, .75); color: rgba(255, 255, 255, .75);
} }
@ -263,7 +259,7 @@ a:hover {
.modal-body { .modal-body {
padding: 0 0; padding: 0 0;
margin: 1vh 1vw; margin: 2vh 2vw;
background-color: rgb(18, 18, 18); background-color: rgb(18, 18, 18);
} }
@ -355,6 +351,65 @@ a:hover {
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
} }
.box #NUDMinus {
color: rgba(255, 255, 255, .55);
background-color: transparent;
border: none;
float: left;
}
.box #NUDMinus:focus {
box-shadow: none;
}
.box #NUDMinus:focus-visible {
outline: none;
}
.box #NUDDisplay {
color: rgba(255, 255, 255, .55);
background-color: transparent;
border: none;
cursor: text;
width: 65%;
}
.box #NUDDisplay:focus {
box-shadow: none;
}
.box #NUDDisplay:focus-visible {
outline: none;
}
.box #NUDPlus {
color: rgba(255, 255, 255, .55);
background-color: transparent;
border: none;
float: right;
}
.box #NUDPlus:focus {
box-shadow: none;
}
.box #NUDPlus:focus-visible {
outline: none;
}
.box #GameJamSelect:focus {
box-shadow: none;
}
.box #GameJamSelect:hover {
color: rgba(255, 255, 255, .75);
}
.box #GameJamSelect ul {
background-color: red;
}
.box { .box {
background-color: rgb(18, 18, 18); background-color: rgb(18, 18, 18);
} }
@ -397,12 +452,11 @@ a:hover {
color: rgba(255, 255, 255, .75); color: rgba(255, 255, 255, .75);
} }
.box #LoginBtn, .box input[type="submit"] {
.box #RegisterBtn {
border: 0; border: 0;
background: none; background: none;
display: block; display: block;
margin: 20px auto 0 auto; margin: 20px auto;
text-align: center; text-align: center;
border: 2px solid rgb(46, 204, 113); border: 2px solid rgb(46, 204, 113);
padding: 14px 40px; padding: 14px 40px;
@ -413,22 +467,7 @@ a:hover {
cursor: pointer; cursor: pointer;
} }
.box #AdminLoginBtn { .box input[type="submit"]:hover {
border: 0;
background: transparent;
color: rgba(255, 255, 255, .55);
display: block;
margin: 0 auto;
text-align: center;
padding: 14px 10px;
outline: none;
border-radius: 24px;
transition: 0.25s;
cursor: pointer;
}
.box #LoginBtn:hover,
.box #RegisterBtn:hover {
background: rgb(46, 204, 113); background: rgb(46, 204, 113);
color: rgba(255, 255, 255, .75); color: rgba(255, 255, 255, .75);
} }
@ -690,6 +729,10 @@ image_gruppenavn{
background-color: #01579b; background-color: #01579b;
border-radius: 50%; border-radius: 50%;
} }
.hasEvent {
background-color: red;;
}
/*Kalender slut*/ /*Kalender slut*/
#return-to-top { #return-to-top {

52
composer.lock generated
View File

@ -103,16 +103,16 @@
}, },
{ {
"name": "illuminate/collections", "name": "illuminate/collections",
"version": "v8.34.0", "version": "v8.32.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/illuminate/collections.git", "url": "https://github.com/illuminate/collections.git",
"reference": "e18d6e4cf03dd597bc3ecd86fefc2023d0c7a5e8" "reference": "d7cc717a00064b40fa63a8ad522042005e1de1ed"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/illuminate/collections/zipball/e18d6e4cf03dd597bc3ecd86fefc2023d0c7a5e8", "url": "https://api.github.com/repos/illuminate/collections/zipball/d7cc717a00064b40fa63a8ad522042005e1de1ed",
"reference": "e18d6e4cf03dd597bc3ecd86fefc2023d0c7a5e8", "reference": "d7cc717a00064b40fa63a8ad522042005e1de1ed",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -153,20 +153,20 @@
"issues": "https://github.com/laravel/framework/issues", "issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework" "source": "https://github.com/laravel/framework"
}, },
"time": "2021-03-19T00:05:33+00:00" "time": "2021-03-08T17:22:22+00:00"
}, },
{ {
"name": "illuminate/container", "name": "illuminate/container",
"version": "v8.34.0", "version": "v8.32.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/illuminate/container.git", "url": "https://github.com/illuminate/container.git",
"reference": "0e38ee1632d470e56aece0079e6e22d13e6bea8e" "reference": "3d6ce613f455093fdf8bd3c81b30104aef0b11e0"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/illuminate/container/zipball/0e38ee1632d470e56aece0079e6e22d13e6bea8e", "url": "https://api.github.com/repos/illuminate/container/zipball/3d6ce613f455093fdf8bd3c81b30104aef0b11e0",
"reference": "0e38ee1632d470e56aece0079e6e22d13e6bea8e", "reference": "3d6ce613f455093fdf8bd3c81b30104aef0b11e0",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -204,20 +204,20 @@
"issues": "https://github.com/laravel/framework/issues", "issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework" "source": "https://github.com/laravel/framework"
}, },
"time": "2021-03-16T19:42:20+00:00" "time": "2021-02-12T21:15:27+00:00"
}, },
{ {
"name": "illuminate/contracts", "name": "illuminate/contracts",
"version": "v8.34.0", "version": "v8.32.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/illuminate/contracts.git", "url": "https://github.com/illuminate/contracts.git",
"reference": "121cea1d8b8772bc7fee99c71ecf0f57c1d77b3b" "reference": "9c7a9868d7485a82663d67109429094c8e4ed56d"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/illuminate/contracts/zipball/121cea1d8b8772bc7fee99c71ecf0f57c1d77b3b", "url": "https://api.github.com/repos/illuminate/contracts/zipball/9c7a9868d7485a82663d67109429094c8e4ed56d",
"reference": "121cea1d8b8772bc7fee99c71ecf0f57c1d77b3b", "reference": "9c7a9868d7485a82663d67109429094c8e4ed56d",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -252,20 +252,20 @@
"issues": "https://github.com/laravel/framework/issues", "issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework" "source": "https://github.com/laravel/framework"
}, },
"time": "2021-03-12T14:45:30+00:00" "time": "2021-02-26T13:17:03+00:00"
}, },
{ {
"name": "illuminate/database", "name": "illuminate/database",
"version": "v8.34.0", "version": "v8.32.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/illuminate/database.git", "url": "https://github.com/illuminate/database.git",
"reference": "74a165fd07b36cc0ea3558fa391b762867af87e8" "reference": "f6a10cebd9bbd188ca66993168fb453439dbb50f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/illuminate/database/zipball/74a165fd07b36cc0ea3558fa391b762867af87e8", "url": "https://api.github.com/repos/illuminate/database/zipball/f6a10cebd9bbd188ca66993168fb453439dbb50f",
"reference": "74a165fd07b36cc0ea3558fa391b762867af87e8", "reference": "f6a10cebd9bbd188ca66993168fb453439dbb50f",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -320,11 +320,11 @@
"issues": "https://github.com/laravel/framework/issues", "issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework" "source": "https://github.com/laravel/framework"
}, },
"time": "2021-03-23T15:12:51+00:00" "time": "2021-03-09T14:06:15+00:00"
}, },
{ {
"name": "illuminate/macroable", "name": "illuminate/macroable",
"version": "v8.34.0", "version": "v8.32.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/illuminate/macroable.git", "url": "https://github.com/illuminate/macroable.git",
@ -370,16 +370,16 @@
}, },
{ {
"name": "illuminate/support", "name": "illuminate/support",
"version": "v8.34.0", "version": "v8.32.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/illuminate/support.git", "url": "https://github.com/illuminate/support.git",
"reference": "b7b27e758b68aad44558c62e7374328835895386" "reference": "2ef7ff288366a1ebe32f633196a1b90bd443acc3"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/illuminate/support/zipball/b7b27e758b68aad44558c62e7374328835895386", "url": "https://api.github.com/repos/illuminate/support/zipball/2ef7ff288366a1ebe32f633196a1b90bd443acc3",
"reference": "b7b27e758b68aad44558c62e7374328835895386", "reference": "2ef7ff288366a1ebe32f633196a1b90bd443acc3",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -434,7 +434,7 @@
"issues": "https://github.com/laravel/framework/issues", "issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework" "source": "https://github.com/laravel/framework"
}, },
"time": "2021-03-21T13:37:37+00:00" "time": "2021-03-05T15:22:14+00:00"
}, },
{ {
"name": "nesbot/carbon", "name": "nesbot/carbon",