Token for groups
This commit is contained in:
@@ -4,6 +4,7 @@ require "../../../bootstrap.php";
|
||||
|
||||
use Backend\Models\Group;
|
||||
use Backend\Models\Password;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
//Start the php session
|
||||
session_start();
|
||||
@@ -17,20 +18,30 @@ if(isset($_POST['login'])){
|
||||
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');
|
||||
$token = Str::random(100);
|
||||
$grouppassword = Password::firstWhere('group_id', $group->id);
|
||||
$grouppassword->remember_token = $token;
|
||||
if($grouppassword->save()){
|
||||
$_SESSION['groupName'] = $groupName;
|
||||
$_SESSION['token'] = $token;
|
||||
$_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=token');
|
||||
}
|
||||
|
||||
}else{
|
||||
session_destroy();
|
||||
header('location: ../Frontend/index.php?login=failed?reason=password');
|
||||
header('location: ../../../Frontend/index.php?login=failed&?reason=password');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
session_destroy();
|
||||
header('location: ../Frontend/index.php?login=failed?reason=group');
|
||||
header('location: ../../../Frontend/index.php?login=failed&?reason=group');
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ require "../../../bootstrap.php";
|
||||
use Backend\Models\Group;
|
||||
use Backend\Models\Password;
|
||||
use Backend\Models\GameJam;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
session_start();
|
||||
|
||||
@@ -33,7 +34,7 @@ if(isset($_POST['reg_group'])){
|
||||
|
||||
$password->password = password_hash($_POST['password'] ,PASSWORD_DEFAULT);
|
||||
|
||||
$token = OAuthProvider::generateToken(100);
|
||||
$token = Str::random(100);
|
||||
|
||||
$password->remember_token = $token;
|
||||
|
||||
|
||||
@@ -2,14 +2,23 @@
|
||||
require "../../../bootstrap.php";
|
||||
|
||||
use Backend\Models\Group;
|
||||
use Backend\Models\Password;
|
||||
|
||||
session_start();
|
||||
if(isset($_SESSION['groupId'])){
|
||||
if (isset($_POST['updateGroup'])) {
|
||||
$_POST['updateGroup']
|
||||
if($group = Group::find($_POST['groupId'])){
|
||||
if ($group->password->remember_token === $_SESSION['token']){
|
||||
$group->group_name = $_POST['group_name'];
|
||||
$group->group_amount = $_POST['group_amount'];
|
||||
$group->game_jam_id = $_POST['game_jam_id'];
|
||||
$group->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user