database And dertory update
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?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::firstWhere('groupName', $groupName );
|
||||
if($group){
|
||||
$hashedPassword = $group->password->password;
|
||||
if(password_verify($password, $hashedPassword )){
|
||||
$_SESSION['groupName'] = $groupName;
|
||||
$_SESSION['groupId'] = $group->id;
|
||||
$_SESSION['success'] = "You are now logged in";
|
||||
header('location: ../Frontend/index.php?login=success');
|
||||
}else{
|
||||
session_destroy();
|
||||
header('location: ../Frontend/index.php?login=failed?reason=password');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
session_destroy();
|
||||
header('location: ../Frontend/index.php?login=failed?reason=group');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
require "../../../bootstrap.php";
|
||||
|
||||
use Backend\Models\Group;
|
||||
use Backend\Models\Password;
|
||||
use Backend\Models\GameJam;
|
||||
|
||||
session_start();
|
||||
|
||||
$groupName = "";
|
||||
$errors = array();
|
||||
|
||||
if(isset($_POST['reg_group'])){
|
||||
|
||||
|
||||
|
||||
|
||||
$group = new Group();
|
||||
|
||||
$group->gameJam()->associate(GameJam::find($_POST['gameJamId']));
|
||||
|
||||
$group->groupName = $groupName = $_POST['groupName'];
|
||||
|
||||
$group->groupAmount = $_POST['groupAmount'];
|
||||
|
||||
if(!$group->save()){
|
||||
return;
|
||||
}
|
||||
$password = New Password();
|
||||
|
||||
$password->group()->associate($group);
|
||||
|
||||
$password->password = password_hash($_POST['password'] ,PASSWORD_DEFAULT);
|
||||
|
||||
if(!$password->save()){
|
||||
return;
|
||||
}
|
||||
|
||||
$_SESSION['groupName'] = $groupName;
|
||||
$_SESSION['groupId'] = $group->id;
|
||||
$_SESSION['success'] = "You are now logged in";
|
||||
header('location: index.php');
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
session_destroy();
|
||||
Reference in New Issue
Block a user