mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Start Front End of Client Portal - Authentication
This commit is contained in:
parent
9effc2ebca
commit
241cb02a86
@ -94,7 +94,7 @@ class Handler extends ExceptionHandler
|
||||
|
||||
switch ($guard) {
|
||||
case 'contact':
|
||||
$login = 'contact.login';
|
||||
$login = 'client.login';
|
||||
break;
|
||||
case 'user':
|
||||
$login = 'login';
|
||||
|
@ -11,15 +11,18 @@
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Auth;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
use Illuminate\Http\Request;
|
||||
use Route;
|
||||
|
||||
class ContactLoginController extends Controller
|
||||
{
|
||||
|
||||
protected $redirectTo = '/contact';
|
||||
use AuthenticatesUsers;
|
||||
|
||||
protected $redirectTo = '/client/dashboard';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@ -33,25 +36,34 @@ class ContactLoginController extends Controller
|
||||
|
||||
public function login(Request $request)
|
||||
{
|
||||
// Validate the form data
|
||||
$this->validate($request, [
|
||||
'email' => 'required|email',
|
||||
'password' => 'required|min:6'
|
||||
]);
|
||||
|
||||
// Attempt to log the user in
|
||||
if (Auth::guard('contact')->attempt(['email' => $request->email, 'password' => $request->password], $request->remember)) {
|
||||
// if successful, then redirect to their intended location
|
||||
return redirect()->intended(route('contact.dashboard'));
|
||||
}
|
||||
|
||||
// if unsuccessful, then redirect back to the login with the form data
|
||||
return redirect()->back()->withInput($request->only('email', 'remember'));
|
||||
Auth::shouldUse('contact');
|
||||
|
||||
$this->validateLogin($request);
|
||||
|
||||
if ($this->hasTooManyLoginAttempts($request)) {
|
||||
$this->fireLockoutEvent($request);
|
||||
|
||||
return response()->json(['message' => 'Too many login attempts, you are being throttled']);
|
||||
}
|
||||
|
||||
if ($this->attemptLogin($request))
|
||||
return redirect()->intended(route('client.dashboard'));
|
||||
else {
|
||||
|
||||
$this->incrementLoginAttempts($request);
|
||||
|
||||
return redirect()->back()->withInput($request->only('email', 'remember'));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function logout()
|
||||
{
|
||||
|
||||
Auth::guard('contact')->logout();
|
||||
return redirect('/contact/login');
|
||||
|
||||
return redirect('/client/login');
|
||||
}
|
||||
}
|
@ -59,6 +59,17 @@ class Kernel extends HttpKernel
|
||||
'bindings',
|
||||
'query_logging',
|
||||
],
|
||||
'client' => [
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
// \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
\App\Http\Middleware\StartupCheck::class,
|
||||
\App\Http\Middleware\QueryLogging::class,
|
||||
],
|
||||
'db' => [
|
||||
\App\Http\Middleware\SetDb::class,
|
||||
],
|
||||
|
@ -29,7 +29,7 @@ class RedirectIfAuthenticated
|
||||
switch ($guard) {
|
||||
case 'contact':
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect()->route('contact.dashboard');
|
||||
return redirect()->route('client.dashboard');
|
||||
}
|
||||
break;
|
||||
case 'user':
|
||||
|
@ -137,6 +137,8 @@ class RouteServiceProvider extends ServiceProvider
|
||||
$this->mapWebRoutes();
|
||||
|
||||
$this->mapContactApiRoutes();
|
||||
|
||||
$this->mapClientApiRoutes();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -182,5 +184,20 @@ class RouteServiceProvider extends ServiceProvider
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/contact.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "client" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapClientApiRoutes()
|
||||
{
|
||||
Route::prefix('')
|
||||
->middleware('client')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/client.php'));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,12 @@
|
||||
<div class="card-header">{{ __('Login') }}</div>
|
||||
|
||||
<div class="card-body">
|
||||
<form method="POST" action="{{ route('contact.login.submit') }}">
|
||||
@if (Session::has('error'))
|
||||
<div class="alert alert-danger">
|
||||
<li>{!! Session::get('error') !!}</li>
|
||||
</div>
|
||||
@endif
|
||||
<form method="POST" action="{{ route('client.login.submit') }}">
|
||||
@csrf
|
||||
|
||||
<div class="form-group row">
|
||||
|
14
routes/client.php
Normal file
14
routes/client.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
Route::get('client/login', 'Auth\ContactLoginController@showLoginForm')->name('client.login');
|
||||
Route::post('client/login', 'Auth\ContactLoginController@login')->name('client.login.submit');
|
||||
|
||||
//todo implement domain DB
|
||||
//Route::group(['middleware' => ['auth:contact', 'domain_db'], 'prefix' => 'client', 'as' => 'client.'], function () {
|
||||
Route::group(['middleware' => ['auth:contact'], 'prefix' => 'client', 'as' => 'client.'], function () {
|
||||
|
||||
Route::get('dashboard', 'ClientPortal\DashboardController@index')->name('dashboard'); // name = (dashboard. index / create / show / update / destroy / edit
|
||||
|
||||
Route::get('logout', 'Auth\ContactLoginController@logout')->name('logout');
|
||||
|
||||
});
|
@ -15,9 +15,6 @@ Route::redirect('/', '/login', 301);
|
||||
Route::get('signup', 'AccountController@index')->name('signup');
|
||||
Route::post('signup', 'AccountController@store')->name('signup.submit');
|
||||
|
||||
Route::get('contact/login', 'Auth\ContactLoginController@showLoginForm')->name('contact.login');
|
||||
Route::post('contact/login', 'Auth\ContactLoginController@login')->name('contact.login.submit');
|
||||
|
||||
/*
|
||||
* Password Reset Routes...
|
||||
*/
|
||||
@ -94,17 +91,7 @@ Route::group(['middleware' => ['url_db']], function () {
|
||||
|
||||
});
|
||||
|
||||
/*
|
||||
Authenticated Contact Routes
|
||||
*/
|
||||
|
||||
Route::group(['prefix' => 'contact', 'middleware' => 'auth:contact'], function () {
|
||||
|
||||
Route::get('/', 'ClientPortal\DashboardController@index')->name('contact.dashboard');
|
||||
|
||||
Route::get('logout', 'Auth\ContactLoginController@logout')->name('contact.logout');
|
||||
|
||||
});
|
||||
|
||||
/*
|
||||
* Injects users translation strings in json format for frontend consumption.
|
||||
|
Loading…
Reference in New Issue
Block a user