2017-01-30 20:40:43 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\ClientAuth;
|
2016-03-05 04:22:54 +01:00
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
2016-05-24 23:02:28 +02:00
|
|
|
use App\Models\Contact;
|
2017-01-30 20:40:43 +01:00
|
|
|
use App\Models\User;
|
2016-03-05 04:22:54 +01:00
|
|
|
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
2017-01-30 20:40:43 +01:00
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Session;
|
2016-03-05 04:22:54 +01:00
|
|
|
|
2016-07-03 18:11:58 +02:00
|
|
|
class AuthController extends Controller
|
|
|
|
{
|
|
|
|
use AuthenticatesUsers;
|
2016-03-05 04:22:54 +01:00
|
|
|
|
2016-07-03 18:11:58 +02:00
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $guard = 'client';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
2016-03-05 04:22:54 +01:00
|
|
|
protected $redirectTo = '/client/dashboard';
|
|
|
|
|
2016-07-03 18:11:58 +02:00
|
|
|
/**
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function showLoginForm()
|
|
|
|
{
|
2017-02-16 04:00:13 +01:00
|
|
|
$data = [
|
|
|
|
'clientauth' => true,
|
|
|
|
];
|
2016-03-05 04:22:54 +01:00
|
|
|
|
2016-07-03 18:11:58 +02:00
|
|
|
return view('clientauth.login')->with($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-03-05 04:22:54 +01:00
|
|
|
* Get the needed authorization credentials from the request.
|
|
|
|
*
|
2017-01-30 20:40:43 +01:00
|
|
|
* @param \Illuminate\Http\Request $request
|
2016-07-03 18:11:58 +02:00
|
|
|
*
|
2016-03-05 04:22:54 +01:00
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
protected function getCredentials(Request $request)
|
|
|
|
{
|
|
|
|
$credentials = $request->only('password');
|
|
|
|
$credentials['id'] = null;
|
2016-05-24 23:02:28 +02:00
|
|
|
|
|
|
|
$contactKey = session('contact_key');
|
2016-07-03 18:11:58 +02:00
|
|
|
if ($contactKey) {
|
2016-05-24 23:02:28 +02:00
|
|
|
$contact = Contact::where('contact_key', '=', $contactKey)->first();
|
2017-01-30 20:40:43 +01:00
|
|
|
if ($contact && ! $contact->is_deleted) {
|
2016-05-24 23:02:28 +02:00
|
|
|
$credentials['id'] = $contact->id;
|
2016-03-05 04:22:54 +01:00
|
|
|
}
|
|
|
|
}
|
2016-07-03 18:11:58 +02:00
|
|
|
|
2016-03-05 04:22:54 +01:00
|
|
|
return $credentials;
|
|
|
|
}
|
2016-07-03 18:11:58 +02:00
|
|
|
|
|
|
|
/**
|
2016-03-05 04:22:54 +01:00
|
|
|
* Validate the user login request.
|
|
|
|
*
|
2017-01-30 20:40:43 +01:00
|
|
|
* @param \Illuminate\Http\Request $request
|
2016-07-03 18:11:58 +02:00
|
|
|
*
|
2016-03-05 04:22:54 +01:00
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
protected function validateLogin(Request $request)
|
|
|
|
{
|
|
|
|
$this->validate($request, [
|
|
|
|
'password' => 'required',
|
|
|
|
]);
|
|
|
|
}
|
2016-05-24 23:02:28 +02:00
|
|
|
|
2016-07-03 18:11:58 +02:00
|
|
|
/**
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2016-05-24 23:02:28 +02:00
|
|
|
public function getSessionExpired()
|
|
|
|
{
|
2017-02-16 04:00:13 +01:00
|
|
|
return view('clientauth.sessionexpired')->with(['clientauth' => true]);
|
2016-05-24 23:02:28 +02:00
|
|
|
}
|
2016-03-05 04:22:54 +01:00
|
|
|
}
|