Made login

This commit is contained in:
neerholt 2021-03-04 13:13:07 +01:00
parent c3479e8e7b
commit 9a38284c8b
6 changed files with 61 additions and 8 deletions

View File

@ -10,10 +10,10 @@ Capsule::schema()->create("groups", function (Blueprint $table){
$table->id(); $table->id();
$table->string("groupName"); $table->string("groupName");
$table->integer("groupAmount"); $table->integer("groupAmount");
$table->foreignId("fkGameJam")->constrained("game_jams"); $table->foreignId("game_jam_id")->constrained("game_jams");
$table->integer("votes")->nullable(); $table->integer("votes")->nullable();
$table->foreignId("fkPassword")->constrained("password"); $table->foreignId("password_id")->constrained("passwords");
$table->foreignId("fkGameData")->nullable()->constrained("game_data"); $table->foreignId("game_data_id")->nullable()->constrained("game_data");
$table->timestamps(); $table->timestamps();
}); });

View File

@ -9,7 +9,7 @@ use Illuminate\Support\Facades\Schema;
Capsule::schema()->create("key_words", function (Blueprint $table){ Capsule::schema()->create("key_words", function (Blueprint $table){
$table->id(); $table->id();
$table->string('keyWord'); $table->string('keyWord');
$table->foreignId("fkGroup")->constrained("groups"); $table->foreignId("group_id")->constrained("groups");
$table->timestamps(); $table->timestamps();
}); });

View File

@ -6,7 +6,7 @@ use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
//Create password table with the rows as id, password, rememberToken and timestamps //Create password table with the rows as id, password, rememberToken and timestamps
Capsule::schema()->create("password", function (Blueprint $table){ Capsule::schema()->create("passwords", function (Blueprint $table){
$table->id(); $table->id();
$table->string('password'); $table->string('password');
$table->rememberToken(); $table->rememberToken();

View File

@ -1 +1,27 @@
<?php <?php
require "../bootstrap.php";
use Backend\Models\Group;
use Backend\Models\Password;
//Start the php session
session_start();
if(isset($_POST['login'])){
$groupName = $_POST["groupName"];
$password = $_POST["password"];
$group = Group::where('groupName', $groupName )->first();
if($group){
$hashedPassword = $group->password()->id;
if(password_verify($password, $hashedPassword )){
$_SESSION['groupName'] = $groupName;
$_SESSION['success'] = "You are now logged in";
header('location: Main.php?yeah=aa');
}
}
}

View File

@ -1,6 +1,4 @@
<?php <?php
use Backend\Models\GameJam; use Backend\Models\GameJam;
@ -11,3 +9,30 @@ $gameJam = GameJam::firstOrCreate([
'name' => "First game jam ever!", 'startTime' => "2021-03-03T12:40", 'endTime' => "2021-04-03T12:40", 'description' => "Det her et en beskrivelse" 'name' => "First game jam ever!", 'startTime' => "2021-03-03T12:40", 'endTime' => "2021-04-03T12:40", 'description' => "Det her et en beskrivelse"
]); ]);
?>
<!DOCTYPE html>
<html>
<title>HTML Tutorial</title>
<body>
<form action="SigningUp.php" method="POST">
<input type="text" name="groupName" placeholder="Group name">
<input type="number" name="groupAmount" placeholder="Group Amount">
<input type="number" name="gameJamId" placeholder="Game Jam id">
<input type="password" name="password" placeholder="password">
<input type="submit" name="reg_group" value="Register">
</form>
<form action="Login.php" method="POST">
<input type="text" name="groupName" placeholder="Group name">
<input type="password" name="password" placeholder="password">
<input type="submit" name="login" value="login">
</form>
</body>
</html>

View File

@ -1,5 +1,7 @@
<?php <?php
require "../bootstrap.php";
use Backend\Models\Group; use Backend\Models\Group;
use Backend\Models\Password; use Backend\Models\Password;
use Backend\Models\GameJam; use Backend\Models\GameJam;
@ -12,7 +14,7 @@ $errors = array();
if(isset($_POST['reg_group'])){ if(isset($_POST['reg_group'])){
$password = New Password; $password = New Password();
$password->password = password_hash($_POST['password'] ,PASSWORD_DEFAULT); $password->password = password_hash($_POST['password'] ,PASSWORD_DEFAULT);