fipamo/app/Services/AuthService.php

38 lines
1.1 KiB
PHP
Raw Normal View History

<?php
namespace App\Services;
use function _\find;
class AuthService
{
protected $config;
protected $request;
public function __construct(SettingsService $config)
{
$this->config = $config;
}
public function check($request)
{
$folks = $this->config->getFolks();
$found = find($folks, ['handle' => $request->handle]);
if ($found) {
if (password_verify($request->password, $found['password'])) {
$request->session()->put('handle', $found['handle']);
$request->session()->put('email', $found['email']);
$request->session()->put('role', $found['role']);
$request->session()->put('avi', $found['avi']);
return ['status' => true, 'message' => 'HEY WELCOME BACK'];
//DO SESSION STUFF
} else {
return ['status' => false, 'message' => 'CHECK THAT PASSWORD'];
//RETURN ERROR
}
} else {
return ['status' => false, 'message' => 'CHECK THAT HANDLE'];
}
}
}