77 lines
1.7 KiB
PHP
77 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Club\Auth;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Customer;
|
|
use Illuminate\Contracts\Auth\StatefulGuard;
|
|
use Illuminate\Contracts\View\View;
|
|
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Arr;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class LoginController extends Controller
|
|
{
|
|
use AuthenticatesUsers;
|
|
|
|
/**
|
|
* Create a new controller instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
$this->middleware('guest:club')->except('logout');
|
|
}
|
|
|
|
/**
|
|
* Get the guard to be used during authentication.
|
|
*
|
|
* @return \Illuminate\Contracts\Auth\StatefulGuard
|
|
*/
|
|
protected function guard(): StatefulGuard
|
|
{
|
|
return Auth::guard('club');
|
|
}
|
|
|
|
/**
|
|
* Show the application's login form.
|
|
*
|
|
* @return \Illuminate\Contracts\View\View
|
|
*/
|
|
public function showLoginForm(): View
|
|
{
|
|
return view('club.auth.login');
|
|
}
|
|
|
|
/**
|
|
* Where to redirect users after login.
|
|
*
|
|
* @return string
|
|
*/
|
|
protected function redirectTo(): string
|
|
{
|
|
return route('club.home.show');
|
|
}
|
|
|
|
/**
|
|
* Attempt to log the user into the application.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @return boolean
|
|
*/
|
|
protected function attemptLogin(Request $request)
|
|
{
|
|
$credentials = $this->credentials($request);
|
|
|
|
$customer = Customer::query()->where('email', Arr::get($credentials, 'email'))->first();
|
|
|
|
if (!$customer) {
|
|
return false;
|
|
}
|
|
// FIXME:DEVELOPMENT LOGIN ANYHOW, replace with CRM.
|
|
$this->guard()->loginUsingId($customer->id);
|
|
return true;
|
|
}
|
|
}
|