ro
064407aa88
a class for members was needed for long term handling of member functions like login, update, status checking, etc so that class was created and the AuthService class was removed as it was redundant and it's functionaity moved to the member class
51 lines
1.3 KiB
PHP
51 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use App\Interfaces\MemberRepositoryInterface;
|
|
use Illuminate\Http\Request;
|
|
|
|
class AuthController extends Controller
|
|
{
|
|
protected $member;
|
|
|
|
public function __construct(
|
|
MemberRepositoryInterface $memberRepository
|
|
) {
|
|
$this->member = $memberRepository;
|
|
}
|
|
|
|
public function enter(Request $request): Response
|
|
{
|
|
$token = csrf_token();
|
|
|
|
$credentials = $request->validate([
|
|
'handle' => ['required'],
|
|
'password' => ['required'],
|
|
]);
|
|
|
|
if ($credentials) {
|
|
$result = $this->member->auth($request);
|
|
if ($result['status']) {
|
|
//$request->session()->regenerate();
|
|
return redirect()->intended('dashboard/start');
|
|
} else {
|
|
return back()->withErrors([
|
|
'error' => $result['message'],
|
|
]);
|
|
}
|
|
} else {
|
|
return back()->withErrors([
|
|
'error' => 'Nope. Check your crendtials, champ',
|
|
]);
|
|
}
|
|
}
|
|
|
|
public function exit(Request $request): Response
|
|
{
|
|
session()->flush();
|
|
return redirect()->intended('dashboard');
|
|
}
|
|
}
|