Login fix
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
require_once "../../../bootstrap.php";
|
||||
require_once (realpath(dirname(__FILE__) ."/../../../bootstrap.php"));
|
||||
|
||||
use Backend\Models\Group;
|
||||
use Backend\Models\Password;
|
||||
@@ -22,25 +22,24 @@ function groupViaToken(string $token): ?Group
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
function isLogin(){
|
||||
function isLogin(): bool
|
||||
{
|
||||
return isset($_SESSION["token"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $password1
|
||||
* @param string $password2
|
||||
* @return bool
|
||||
*/
|
||||
function passwordValidate(string $password1, string $password2 ){
|
||||
if($password1 === $password2){
|
||||
function passwordValidate(string $password1): bool
|
||||
{
|
||||
$uppercase = preg_match('@[A-Z]@', $password1);
|
||||
$lowercase = preg_match('@[a-z]@', $password1);
|
||||
$number = preg_match('@[0-9]@', $password1);
|
||||
$specialChars = preg_match('@[^\w]@', $password1);
|
||||
|
||||
if(!$uppercase || !$lowercase || !$number || !$specialChars || (strlen($password1) < 8 && strlen($password1) > 255)) {
|
||||
if(!$uppercase || !$lowercase || !$number || !$specialChars || (strlen($password1) >= 8 && strlen($password1) <= 255) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else false;
|
||||
else return false;
|
||||
}
|
||||
@@ -45,4 +45,4 @@ if(isset($_POST['login'])){
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ require_once "../Admin/Admin.php";
|
||||
|
||||
use Backend\Models\Group;
|
||||
|
||||
session_start();
|
||||
//session_start();
|
||||
if(isAdmin()){
|
||||
if(isset($_POST['restPassword'])){
|
||||
$group = Group::find($_POST['groupId']);
|
||||
|
||||
@@ -16,7 +16,7 @@ $errors = array();
|
||||
if(isset($_POST['regGroup'])){
|
||||
|
||||
|
||||
if(passwordValidate($pass = $_POST['password1'], $_POST['password2'])){
|
||||
if(passwordValidate($pass = $_POST['password'])){
|
||||
$group = new Group();
|
||||
|
||||
$group->gameJam()->associate(GameJam::find($_POST['gameJamId']));
|
||||
|
||||
Reference in New Issue
Block a user