1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00
invoiceninja/app/Http/Controllers/ClientAuth/AuthController.php

90 lines
2.0 KiB
PHP
Raw Normal View History

<?php namespace App\Http\Controllers\ClientAuth;
use Session;
use Illuminate\Http\Request;
use App\Models\User;
use App\Http\Controllers\Controller;
2016-05-24 23:02:28 +02:00
use App\Models\Contact;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class AuthController extends Controller
{
use AuthenticatesUsers;
/**
* @var string
*/
protected $guard = 'client';
/**
* @var string
*/
protected $redirectTo = '/client/dashboard';
/**
* @return mixed
*/
public function showLoginForm()
{
$data = [];
2016-05-24 23:02:28 +02:00
$contactKey = session('contact_key');
if ($contactKey) {
2016-05-24 23:02:28 +02:00
$contact = Contact::where('contact_key', '=', $contactKey)->first();
if ($contact && !$contact->is_deleted) {
$account = $contact->account;
2016-04-29 23:50:21 +02:00
$data['account'] = $account;
$data['clientFontUrl'] = $account->getFontsUrl();
}
}
return view('clientauth.login')->with($data);
}
/**
* Get the needed authorization credentials from the request.
*
* @param \Illuminate\Http\Request $request
*
* @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');
if ($contactKey) {
2016-05-24 23:02:28 +02:00
$contact = Contact::where('contact_key', '=', $contactKey)->first();
if ($contact && !$contact->is_deleted) {
$credentials['id'] = $contact->id;
}
}
return $credentials;
}
/**
* Validate the user login request.
*
* @param \Illuminate\Http\Request $request
*
* @return void
*/
protected function validateLogin(Request $request)
{
$this->validate($request, [
'password' => 'required',
]);
}
2016-05-24 23:02:28 +02:00
/**
* @return mixed
*/
2016-05-24 23:02:28 +02:00
public function getSessionExpired()
{
return view('clientauth.sessionexpired');
}
}