Game-Jaming/Backend/Controllers/Group/Group.php

45 lines
1.0 KiB
PHP
Raw Normal View History

2021-03-09 12:29:49 +00:00
<?php
2021-03-09 13:43:39 +00:00
require_once "../../../bootstrap.php";
2021-03-09 12:29:49 +00:00
use Backend\Models\Group;
use Backend\Models\Password;
/**
* @param string $token
* @return Group|null ;
2021-03-09 12:29:49 +00:00
*/
function groupViaToken(string $token): ?Group
{
2021-03-09 12:29:49 +00:00
2021-03-09 13:43:39 +00:00
if($password = Password::firstWhere('remember_token', $token)){
return Group::find($password->group_id);
}
return null;
}
/**
* @return bool
*/
2021-03-09 13:43:39 +00:00
function isLogin(){
return isset($_SESSION["token"]);
}
/**
* @param string $password1
* @param string $password2
* @return bool
*/
function passwordValidate(string $password1, string $password2 ){
if($password1 === $password2){
$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)) {
return true;
}
}
else false;
2021-03-09 12:29:49 +00:00
}