2024-03-01 20:34:36 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Services;
|
|
|
|
|
|
|
|
use function _\find;
|
|
|
|
|
|
|
|
class AuthService
|
|
|
|
{
|
|
|
|
protected $config;
|
2024-03-03 20:48:22 +01:00
|
|
|
protected $request;
|
2024-03-01 20:34:36 +01:00
|
|
|
|
|
|
|
public function __construct(SettingsService $config)
|
|
|
|
{
|
|
|
|
$this->config = $config;
|
|
|
|
}
|
|
|
|
|
2024-03-03 20:48:22 +01:00
|
|
|
public function check($request)
|
2024-03-01 20:34:36 +01:00
|
|
|
{
|
|
|
|
$folks = $this->config->getFolks();
|
2024-03-03 20:48:22 +01:00
|
|
|
$found = find($folks, ['handle' => $request->handle]);
|
2024-03-01 20:34:36 +01:00
|
|
|
if ($found) {
|
2024-03-03 20:48:22 +01:00
|
|
|
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'];
|
2024-03-01 20:34:36 +01:00
|
|
|
//DO SESSION STUFF
|
|
|
|
} else {
|
2024-03-03 20:48:22 +01:00
|
|
|
return ['status' => false, 'message' => 'CHECK THAT PASSWORD'];
|
2024-03-01 20:34:36 +01:00
|
|
|
//RETURN ERROR
|
|
|
|
}
|
|
|
|
} else {
|
2024-03-03 20:48:22 +01:00
|
|
|
return ['status' => false, 'message' => 'CHECK THAT HANDLE'];
|
2024-03-01 20:34:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|