fipamo/app/Services/AuthService.php
ro c77eeafb2c
Login Auth Flow
Added controller to handle the login process and session management
that stores information about the person that has logged in so that info
is available through out the app when logged in
2024-03-03 13:48:22 -06:00

38 lines
1.1 KiB
PHP

<?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'];
}
}
}