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']);
}
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['admin'] = true;
$_SESSION['success'] = "You are now logged in";
makeAdminLogin($userName);
http_response_code(200);
}else{
session_destroy();

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -82,15 +82,11 @@
</a>
</li>
</ul>
<a id="AdminPanel" type="button" class="nav-link RightNavButton" style="display: none;">
Admin Panel
</a>
<a id="NavLogin" type="button" class="nav-link RightNavButton" data-bs-toggle="modal" data-bs-target="#LoginModal" style="display: block;">
<a id="NavLogin" type="button" class="nav-link LoginButton" data-bs-toggle="modal" data-bs-target="#LoginModal" style="display: block;">
Login
</a>
<a id="NavUser" class="nav-link RightNavText" style="display: none;"></a>
<a id="UserLogout" type="button" class="nav-link RightNavButton" style="display: none;">
Logout
<a id="NavUser" type="button" class="nav-link LoginButton" style="display: none;">
</a>
</div>
</div>
@ -124,56 +120,67 @@
<div class="modal-body">
<div class="tab-content" id="ModalLoginTabContent">
<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">
Team Login
</h1>
<input id="loginUsername" type="text" name="groupName" placeholder="Gruppe navn">
<input id="loginPassword" type="password" name="password" placeholder="Password">
<input id="LoginBtn" type="submit" name="login" value="Login">
<input id="AdminLoginBtn" type="submit" name="aLogin" value="Login som admin">
</form>
</div>
<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">
Team Registrering
</h1>
<input id="username" type="text" name="" placeholder="Gruppe navn">
<input id="pass1" type="password" class="" name="" placeholder="Password">
<input id="pass2" type="password" name="" placeholder="Gentag Password">
<div class="form-check" style="display: table; margin: auto;">
<input class="form-check-input" type="checkbox" value="" id="flexCheckDefault">
<label class="form-check-label" for="flexCheckDefault">
Jeg accepterer Vilkår og betingelser
</label>
<input id="username" type="text" name="groupName" placeholder="Unikt gruppe navn">
<input id="pass1" type="password" class="" placeholder="Password">
<input id="pass2" type="password" class="" name="password" placeholder="Gentag Password">
<select id="GameJamSelect" class="form-select" aria-label="Default select example">
</select>
<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 id="pass_info">
<h5>Passsword skal opfylde følgende krav :</h5>
<ul>
<li id="letter" class="invalid">
Mindst 1 <strong>bogstave
</strong>
Mindst 1 <strong>lille bogstave</strong>
</li>
<li id="capital" class="invalid">
Mindst 1 <strong>stort bogstave
</strong>
Mindst 1 <strong>stort bogstave</strong>
</li>
<li id="number" class="invalid">
Mindst 1 <strong>tal
</strong>
Mindst 1 <strong>tal</strong>
</li>
<li id="length" class="invalid">
Mindst <strong>8 tegn langt
</strong>
<li id="special" class="invalid">
Mindst 1 <strong>special tegn</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>
</ul>
</div>
<input type="submit" name="" value="Registrer" href="#">
<input id="RegisterBtn" type="submit" name="regGroup" value="Registrer">
</form>
</div>
</div>

View File

@ -1,36 +1,28 @@
$(document).ready(function () {
// Register Start
let selectedGameJam;
let MemberSize = $('#NUDDisplay').text();
let displayValue = 0;
let AvailableJams = [
let arr = [
{"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
axios.get('/Backend/Controllers/GameJam/GetGameJam.php')
.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({
id: resArr[i].id,
Gamejam: resArr[i].name
arr.push({
id: res.data.data[i].id,
Gamejam: res.data.data[i].name
});
}
$.each(AvailableJams, function(i, data) {
$.each(arr, function(i, data) {
if (i === 0)
{
$('#GameJamSelect').append('<option disabled selected value="' + data.id + '">' + data.Gamejam + '</option>');
@ -162,15 +154,7 @@ $(document).ready(function () {
axios.post(URL, formData, {
header: 'multipart/form-data'
}).then(res => {
if (res.status == 201)
{
let LoginModalElem = document.getElementById('LoginModal')
let LoginModal = bootstrap.Modal.getInstance(LoginModalElem);
LoginModal.hide();
LoggedInUser();
}
console.log(res);
}).catch(error => {
console.log(error);
});
@ -205,14 +189,20 @@ $(document).ready(function () {
$('#NUDDisplay').text(displayValue);
}
});
async function GetGroupNames() {
const res = await axios.get('/Backend/Controllers/Group/GetGroup.php');
return res.data;
}
// Register end
// Login start
$('#LoginForm').submit(function(e) {
let URL = "/Backend/Controllers/Group/Login.php";
$('#loginUsername').attr('name') = "groupName";
let form = $('#LoginForm')[0];
let formData = new FormData(form);
@ -221,17 +211,13 @@ $(document).ready(function () {
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();
console.log('Logged in');
}
}).catch(error => {
console.log(error);
@ -240,94 +226,4 @@ $(document).ready(function () {
e.preventDefault();
})
// 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;
}
.RightNavText {
color: rgba(255, 255, 255, .75);
}
.RightNavButton {
.LoginButton {
color: rgba(255, 255, 255, .55);
}
.RightNavButton:hover {
.LoginButton:hover {
color: rgba(255, 255, 255, .75);
}
@ -263,7 +259,7 @@ a:hover {
.modal-body {
padding: 0 0;
margin: 1vh 1vw;
margin: 2vh 2vw;
background-color: rgb(18, 18, 18);
}
@ -355,6 +351,65 @@ a:hover {
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 {
background-color: rgb(18, 18, 18);
}
@ -397,12 +452,11 @@ a:hover {
color: rgba(255, 255, 255, .75);
}
.box #LoginBtn,
.box #RegisterBtn {
.box input[type="submit"] {
border: 0;
background: none;
display: block;
margin: 20px auto 0 auto;
margin: 20px auto;
text-align: center;
border: 2px solid rgb(46, 204, 113);
padding: 14px 40px;
@ -413,22 +467,7 @@ a:hover {
cursor: pointer;
}
.box #AdminLoginBtn {
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 {
.box input[type="submit"]:hover {
background: rgb(46, 204, 113);
color: rgba(255, 255, 255, .75);
}
@ -690,6 +729,10 @@ image_gruppenavn{
background-color: #01579b;
border-radius: 50%;
}
.hasEvent {
background-color: red;;
}
/*Kalender slut*/
#return-to-top {

52
composer.lock generated
View File

@ -103,16 +103,16 @@
},
{
"name": "illuminate/collections",
"version": "v8.34.0",
"version": "v8.32.1",
"source": {
"type": "git",
"url": "https://github.com/illuminate/collections.git",
"reference": "e18d6e4cf03dd597bc3ecd86fefc2023d0c7a5e8"
"reference": "d7cc717a00064b40fa63a8ad522042005e1de1ed"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/collections/zipball/e18d6e4cf03dd597bc3ecd86fefc2023d0c7a5e8",
"reference": "e18d6e4cf03dd597bc3ecd86fefc2023d0c7a5e8",
"url": "https://api.github.com/repos/illuminate/collections/zipball/d7cc717a00064b40fa63a8ad522042005e1de1ed",
"reference": "d7cc717a00064b40fa63a8ad522042005e1de1ed",
"shasum": ""
},
"require": {
@ -153,20 +153,20 @@
"issues": "https://github.com/laravel/framework/issues",
"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",
"version": "v8.34.0",
"version": "v8.32.1",
"source": {
"type": "git",
"url": "https://github.com/illuminate/container.git",
"reference": "0e38ee1632d470e56aece0079e6e22d13e6bea8e"
"reference": "3d6ce613f455093fdf8bd3c81b30104aef0b11e0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/container/zipball/0e38ee1632d470e56aece0079e6e22d13e6bea8e",
"reference": "0e38ee1632d470e56aece0079e6e22d13e6bea8e",
"url": "https://api.github.com/repos/illuminate/container/zipball/3d6ce613f455093fdf8bd3c81b30104aef0b11e0",
"reference": "3d6ce613f455093fdf8bd3c81b30104aef0b11e0",
"shasum": ""
},
"require": {
@ -204,20 +204,20 @@
"issues": "https://github.com/laravel/framework/issues",
"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",
"version": "v8.34.0",
"version": "v8.32.1",
"source": {
"type": "git",
"url": "https://github.com/illuminate/contracts.git",
"reference": "121cea1d8b8772bc7fee99c71ecf0f57c1d77b3b"
"reference": "9c7a9868d7485a82663d67109429094c8e4ed56d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/contracts/zipball/121cea1d8b8772bc7fee99c71ecf0f57c1d77b3b",
"reference": "121cea1d8b8772bc7fee99c71ecf0f57c1d77b3b",
"url": "https://api.github.com/repos/illuminate/contracts/zipball/9c7a9868d7485a82663d67109429094c8e4ed56d",
"reference": "9c7a9868d7485a82663d67109429094c8e4ed56d",
"shasum": ""
},
"require": {
@ -252,20 +252,20 @@
"issues": "https://github.com/laravel/framework/issues",
"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",
"version": "v8.34.0",
"version": "v8.32.1",
"source": {
"type": "git",
"url": "https://github.com/illuminate/database.git",
"reference": "74a165fd07b36cc0ea3558fa391b762867af87e8"
"reference": "f6a10cebd9bbd188ca66993168fb453439dbb50f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/database/zipball/74a165fd07b36cc0ea3558fa391b762867af87e8",
"reference": "74a165fd07b36cc0ea3558fa391b762867af87e8",
"url": "https://api.github.com/repos/illuminate/database/zipball/f6a10cebd9bbd188ca66993168fb453439dbb50f",
"reference": "f6a10cebd9bbd188ca66993168fb453439dbb50f",
"shasum": ""
},
"require": {
@ -320,11 +320,11 @@
"issues": "https://github.com/laravel/framework/issues",
"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",
"version": "v8.34.0",
"version": "v8.32.1",
"source": {
"type": "git",
"url": "https://github.com/illuminate/macroable.git",
@ -370,16 +370,16 @@
},
{
"name": "illuminate/support",
"version": "v8.34.0",
"version": "v8.32.1",
"source": {
"type": "git",
"url": "https://github.com/illuminate/support.git",
"reference": "b7b27e758b68aad44558c62e7374328835895386"
"reference": "2ef7ff288366a1ebe32f633196a1b90bd443acc3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/support/zipball/b7b27e758b68aad44558c62e7374328835895386",
"reference": "b7b27e758b68aad44558c62e7374328835895386",
"url": "https://api.github.com/repos/illuminate/support/zipball/2ef7ff288366a1ebe32f633196a1b90bd443acc3",
"reference": "2ef7ff288366a1ebe32f633196a1b90bd443acc3",
"shasum": ""
},
"require": {
@ -434,7 +434,7 @@
"issues": "https://github.com/laravel/framework/issues",
"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",