for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Created by PhpStorm.
* User: afshin
* Date: 11/24/17
* Time: 1:11 PM
*/
namespace Core\Services;
use App\DataAccess\User\UserDataAccess;
use Core\Config;
use Core\Interfaces\_Service;
class AuthService extends _Service
{
public function user()
return UserDataAccess::getUserById(isset($_SESSION['user']['user_id']) ? $_SESSION['user']['user_id'] : 0);
}
public function check()
return isset($_SESSION['user']['user_id']);
public function attempt(string $loginField,string $password)
$user = UserDataAccess::getUserLoginField($loginField);
if (!$user) {
return [
'type'=>'error',
'message'=> 'User Not Exists',
];
$setting = Config::get('settings.auth');
if($setting['2step']){
$this->twoStepAuth();
}else{
if ($this->checkPass($password,$user->password)) {
password
App\Model\User
Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.
$_SESSION['user']['user_id'] = $user->id;
$_SESSION['user']['mobile'] = $user->mobile;
mobile
'type'=>'success',
'message'=> 'Logined',
'message'=> 'password mismatch',
'message'=> 'problem!',
public function checkPass($password,$database_pass)
if($database_pass == $password){
return true;
return false;
public function twoStepAuth()
public function logout()
unset($_SESSION['user']);
Checks if undeclared accessed properties appear in database migrations and if the creating migration is correct.