Route cosmetic layout updates, and standardise on using /home to redirect back to the homescreen, and standardise usage of redirect()
This commit is contained in:
parent
256e4c6260
commit
8d72c1ceb5
@ -27,7 +27,7 @@ class SocialLoginController extends Controller
|
|||||||
$openiduser = Socialite::with($provider)->user();
|
$openiduser = Socialite::with($provider)->user();
|
||||||
|
|
||||||
if (! $openiduser)
|
if (! $openiduser)
|
||||||
return redirect('/home')
|
return redirect('home')
|
||||||
->with('error','No user details obtained.');
|
->with('error','No user details obtained.');
|
||||||
|
|
||||||
$oo = ProviderOauth::firstOrCreate(['name'=>$provider,'active'=>TRUE]);
|
$oo = ProviderOauth::firstOrCreate(['name'=>$provider,'active'=>TRUE]);
|
||||||
@ -43,7 +43,7 @@ class SocialLoginController extends Controller
|
|||||||
$user = User::where('email',$openiduser->email)->first();
|
$user = User::where('email',$openiduser->email)->first();
|
||||||
|
|
||||||
if ((! $user) || (! $user->active))
|
if ((! $user) || (! $user->active))
|
||||||
return redirect('/login')
|
return redirect('login')
|
||||||
->with('error','Invalid account, or account inactive, please contact an admin.');
|
->with('error','Invalid account, or account inactive, please contact an admin.');
|
||||||
|
|
||||||
return $this->link($provider,$aoo,$user);
|
return $this->link($provider,$aoo,$user);
|
||||||
@ -54,7 +54,7 @@ class SocialLoginController extends Controller
|
|||||||
|
|
||||||
// If there are too many users, then we have a problem
|
// If there are too many users, then we have a problem
|
||||||
} elseif ($aoo->count() > 1) {
|
} elseif ($aoo->count() > 1) {
|
||||||
return redirect('/login')
|
return redirect('login')
|
||||||
->with('error','Seems you have multiple oauth IDs, please contact an admin.');
|
->with('error','Seems you have multiple oauth IDs, please contact an admin.');
|
||||||
|
|
||||||
// User is using OAUTH for the first time.
|
// User is using OAUTH for the first time.
|
||||||
@ -73,11 +73,11 @@ class SocialLoginController extends Controller
|
|||||||
|
|
||||||
// If there are too many users, then we have a problem
|
// If there are too many users, then we have a problem
|
||||||
} elseif ($uo->count() > 1) {
|
} elseif ($uo->count() > 1) {
|
||||||
return redirect('/login')
|
return redirect('login')
|
||||||
->with('error','Seems you have multiple accounts, please contact an admin.');
|
->with('error','Seems you have multiple accounts, please contact an admin.');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return redirect('/login')
|
return redirect('login')
|
||||||
->with('error','Seems you dont have an account with that email, please contact an admin.');
|
->with('error','Seems you dont have an account with that email, please contact an admin.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,7 +91,7 @@ class SocialLoginController extends Controller
|
|||||||
$openiduser = Socialite::with($provider)->user();
|
$openiduser = Socialite::with($provider)->user();
|
||||||
|
|
||||||
if (! $openiduser)
|
if (! $openiduser)
|
||||||
return redirect('/home')
|
return redirect('home')
|
||||||
->with('error','No user details obtained.');
|
->with('error','No user details obtained.');
|
||||||
|
|
||||||
$po = ProviderOauth::where('name',$provider)->singleOrFail();
|
$po = ProviderOauth::where('name',$provider)->singleOrFail();
|
||||||
@ -137,12 +137,12 @@ class SocialLoginController extends Controller
|
|||||||
|
|
||||||
// Check our email matches
|
// Check our email matches
|
||||||
if (Arr::get($aoo->oauth_data,'email','invalid') !== $request->post('email'))
|
if (Arr::get($aoo->oauth_data,'email','invalid') !== $request->post('email'))
|
||||||
return redirect('/login')
|
return redirect('login')
|
||||||
->with('error','Account details didnt match to make link.');
|
->with('error','Account details didnt match to make link.');
|
||||||
|
|
||||||
// Check our token matches
|
// Check our token matches
|
||||||
if ($aoo->link_token !== $request->post('token'))
|
if ($aoo->link_token !== $request->post('token'))
|
||||||
return redirect('/login')
|
return redirect('login')
|
||||||
->with('error','Token details didnt match to make link.');
|
->with('error','Token details didnt match to make link.');
|
||||||
|
|
||||||
// Load our email.
|
// Load our email.
|
||||||
|
@ -34,8 +34,7 @@ class CheckoutController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $o->wasRecentlyCreated
|
return $o->wasRecentlyCreated
|
||||||
? redirect()
|
? redirect('a/checkout/'.$o->id)
|
||||||
->to('a/checkout/'.$o->id)
|
|
||||||
->with('success','Checkout added')
|
->with('success','Checkout added')
|
||||||
: redirect()
|
: redirect()
|
||||||
->back()
|
->back()
|
||||||
|
@ -50,7 +50,7 @@ class HomeController extends Controller
|
|||||||
} catch (ExpiredInviteCode $e) {
|
} catch (ExpiredInviteCode $e) {
|
||||||
Log::alert(sprintf('User is using an expired token for invoice [%s] using [%s]',$o->id,$code));
|
Log::alert(sprintf('User is using an expired token for invoice [%s] using [%s]',$o->id,$code));
|
||||||
|
|
||||||
return redirect()->to('/login');
|
return redirect('login');
|
||||||
|
|
||||||
} catch (DoormanException $e) {
|
} catch (DoormanException $e) {
|
||||||
Log::alert(sprintf('An attempt to read invoice id [%s] using [%s]',$o->id,$code));
|
Log::alert(sprintf('An attempt to read invoice id [%s] using [%s]',$o->id,$code));
|
||||||
@ -72,6 +72,6 @@ class HomeController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function service_progress(Service $o,string $status)
|
public function service_progress(Service $o,string $status)
|
||||||
{
|
{
|
||||||
return redirect()->to($o->action($status) ?: url('u/service',$o->id));
|
return redirect($o->action($status) ?: url('u/service',$o->id));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -63,8 +63,7 @@ class PaymentController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $o->wasRecentlyCreated
|
return $o->wasRecentlyCreated
|
||||||
? redirect()
|
? redirect('r/payment/'.$o->id)
|
||||||
->to('r/payment/'.$o->id)
|
|
||||||
->with('success','Payment added')
|
->with('success','Payment added')
|
||||||
: redirect()
|
: redirect()
|
||||||
->back()
|
->back()
|
||||||
|
@ -34,8 +34,7 @@ class PaypalController extends Controller
|
|||||||
|
|
||||||
public function cancel()
|
public function cancel()
|
||||||
{
|
{
|
||||||
return redirect()
|
return redirect(self::cart_url);
|
||||||
->to(self::cart_url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,8 +51,7 @@ class PaypalController extends Controller
|
|||||||
$cart = request()->session()->get('invoice.cart');
|
$cart = request()->session()->get('invoice.cart');
|
||||||
|
|
||||||
if (! $cart)
|
if (! $cart)
|
||||||
return redirect()
|
return redirect('home');
|
||||||
->to('u/home');
|
|
||||||
|
|
||||||
$invoices = Invoice::find($cart);
|
$invoices = Invoice::find($cart);
|
||||||
|
|
||||||
@ -113,15 +111,13 @@ class PaypalController extends Controller
|
|||||||
} catch (HttpException $e) {
|
} catch (HttpException $e) {
|
||||||
Log::error('Paypal Exception',['request'=>$paypal,'response'=>$e->getMessage()]);
|
Log::error('Paypal Exception',['request'=>$paypal,'response'=>$e->getMessage()]);
|
||||||
|
|
||||||
return redirect()
|
return redirect(self::cart_url)
|
||||||
->to(self::cart_url)
|
|
||||||
->withErrors('Paypal Exception: '.$e->getCode());
|
->withErrors('Paypal Exception: '.$e->getCode());
|
||||||
|
|
||||||
} catch (\HttpException $e) {
|
} catch (\HttpException $e) {
|
||||||
Log::error('HTTP Exception',['request'=>$this->client,'response'=>$e->getMessage()]);
|
Log::error('HTTP Exception',['request'=>$this->client,'response'=>$e->getMessage()]);
|
||||||
|
|
||||||
return redirect()
|
return redirect(self::cart_url)
|
||||||
->to(self::cart_url)
|
|
||||||
->withErrors('HTTP Exception: '.$e->getCode());
|
->withErrors('HTTP Exception: '.$e->getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,8 +134,7 @@ class PaypalController extends Controller
|
|||||||
return redirect()
|
return redirect()
|
||||||
->away($redirect_url);
|
->away($redirect_url);
|
||||||
|
|
||||||
return redirect()
|
return redirect(self::cart_url)
|
||||||
->to(self::cart_url)
|
|
||||||
->withErrors('An error occurred with Paypal?');
|
->withErrors('An error occurred with Paypal?');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,23 +187,20 @@ class PaypalController extends Controller
|
|||||||
->away($redirect_url);
|
->away($redirect_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()
|
return redirect(self::cart_url)
|
||||||
->to(self::cart_url)
|
|
||||||
->withErrors('An error occurred with Paypal?');
|
->withErrors('An error occurred with Paypal?');
|
||||||
|
|
||||||
} catch (\HttpException $e) {
|
} catch (\HttpException $e) {
|
||||||
Log::error('HTTP Exception',['request'=>$paypal,'response'=>$e->getMessage()]);
|
Log::error('HTTP Exception',['request'=>$paypal,'response'=>$e->getMessage()]);
|
||||||
|
|
||||||
return redirect()
|
return redirect(self::cart_url)
|
||||||
->to(self::cart_url)
|
|
||||||
->withErrors('HTTP Exception: '.$e->getCode());
|
->withErrors('HTTP Exception: '.$e->getCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((! $response) || (! $response->result->purchase_units)) {
|
if ((! $response) || (! $response->result->purchase_units)) {
|
||||||
Log::error('Paypal Capture: No Purchase Units?');
|
Log::error('Paypal Capture: No Purchase Units?');
|
||||||
|
|
||||||
return redirect()
|
return redirect(self::cart_url)
|
||||||
->to(self::cart_url)
|
|
||||||
->withErrors('Paypal Exception: NPU');
|
->withErrors('Paypal Exception: NPU');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,8 +259,7 @@ class PaypalController extends Controller
|
|||||||
|
|
||||||
Log::info('Paypal Payment Recorded',['po'=>$po->id]);
|
Log::info('Paypal Payment Recorded',['po'=>$po->id]);
|
||||||
|
|
||||||
return redirect()
|
return redirect('home')
|
||||||
->to('u/home')
|
|
||||||
->with('success','Payment recorded thank you.');
|
->with('success','Payment recorded thank you.');
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -113,7 +113,7 @@ class ServiceController extends Controller
|
|||||||
$np->pivot->effective_at = Carbon::now();
|
$np->pivot->effective_at = Carbon::now();
|
||||||
$np->pivot->save();
|
$np->pivot->save();
|
||||||
|
|
||||||
return redirect()->to(url('u/service',[$o->id]));
|
return redirect(url('u/service',[$o->id]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('theme.backend.adminlte.service.change_pending')
|
return view('theme.backend.adminlte.service.change_pending')
|
||||||
@ -191,7 +191,7 @@ class ServiceController extends Controller
|
|||||||
|
|
||||||
// An Error Condition
|
// An Error Condition
|
||||||
if (is_null($result))
|
if (is_null($result))
|
||||||
return redirect()->to('u/service/'.$o->id);
|
return redirect('u/service/'.$o->id);
|
||||||
|
|
||||||
elseif ($result instanceof RedirectResponse)
|
elseif ($result instanceof RedirectResponse)
|
||||||
return $result;
|
return $result;
|
||||||
@ -213,7 +213,7 @@ class ServiceController extends Controller
|
|||||||
$stage = ''; // @todo this is temporary, we havent written the code to automatically jump to the next stage if wecan
|
$stage = ''; // @todo this is temporary, we havent written the code to automatically jump to the next stage if wecan
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->to('u/service/'.$o->id);
|
return redirect('u/service/'.$o->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,7 +30,9 @@ class SupplierController extends Controller
|
|||||||
$o->save();
|
$o->save();
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return redirect()->back()->withErrors($e->getMessage())->withInput();
|
return redirect()
|
||||||
|
->back()
|
||||||
|
->withErrors($e->getMessage())->withInput();
|
||||||
}
|
}
|
||||||
|
|
||||||
$o->load(['detail']);
|
$o->load(['detail']);
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
$ao->load(['services:id,active,account_id']);
|
$ao->load(['services:id,active,account_id']);
|
||||||
@endphp
|
@endphp
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="{{ url('r/switch/start',$ao->user_id) }}"><i class="fas fa-external-link-alt"></i></a></td>
|
<td><a href="{{ url('switch/start',$ao->user_id) }}"><i class="fas fa-external-link-alt"></i></a></td>
|
||||||
<td><a href="{{ url('u/home',$ao->user_id) }}">{{ $ao->name }}</a></td>
|
<td><a href="{{ url('u/home',$ao->user_id) }}">{{ $ao->name }}</a></td>
|
||||||
<td class="text-right">{{ $ao->services->where('active',TRUE)->count() }} <small>/{{ $ao->services->count() }}</small></td>
|
<td class="text-right">{{ $ao->services->where('active',TRUE)->count() }} <small>/{{ $ao->services->count() }}</small></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
|
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
@if($user->switched)
|
@if($user->switched)
|
||||||
<a href="{{ url('/admin/switch/stop') }}" class="dropdown-item">
|
<a href="{{ url('switch/stop') }}" class="dropdown-item">
|
||||||
<i class="fas fa-sign-out-alt mr-2"></i> {{ trans('adminlte_lang::message.switchoff') }}
|
<i class="fas fa-sign-out-alt mr-2"></i> {{ trans('adminlte_lang::message.switchoff') }}
|
||||||
</a>
|
</a>
|
||||||
@else
|
@else
|
||||||
|
@ -18,8 +18,7 @@ use App\Http\Controllers\{AdminController,
|
|||||||
SearchController,
|
SearchController,
|
||||||
ServiceController,
|
ServiceController,
|
||||||
SupplierController,
|
SupplierController,
|
||||||
UserController,
|
UserController};
|
||||||
Wholesale\ReportController};
|
|
||||||
use App\Models\Supplier;
|
use App\Models\Supplier;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -42,8 +41,8 @@ Auth::routes([
|
|||||||
'confirm' => false, // for additional password confirmations
|
'confirm' => false, // for additional password confirmations
|
||||||
'verify' => false, // for email verification
|
'verify' => false, // for email verification
|
||||||
]);
|
]);
|
||||||
Route::get('logout',[LoginController::class,'logout'])
|
// Auth::routes doesnt provide a get /logout path, so we'll specify it here
|
||||||
->name('logout-get');
|
Route::get('logout',[LoginController::class,'logout']);
|
||||||
|
|
||||||
// Frontend Routes (Non-Authed Users)
|
// Frontend Routes (Non-Authed Users)
|
||||||
Route::view('/','theme.frontend.metronic.welcome.home');
|
Route::view('/','theme.frontend.metronic.welcome.home');
|
||||||
@ -54,21 +53,35 @@ Route::redirect('passkey/loggedin','/u/home');
|
|||||||
|
|
||||||
Route::get('search',[SearchController::class,'search']);
|
Route::get('search',[SearchController::class,'search']);
|
||||||
|
|
||||||
Route::get('pay/paypal/authorise',[PaypalController::class,'authorise']);
|
// Paypal paths
|
||||||
Route::get('pay/paypal/cancel',[PaypalController::class,'cancel']);
|
Route::controller(PaypalController::class)
|
||||||
Route::get('pay/paypal/capture',[PaypalController::class,'capture']);
|
->prefix('pay/paypal')
|
||||||
|
->group(function() {
|
||||||
|
Route::get('authorise','authorise');
|
||||||
|
Route::get('cancel','cancel');
|
||||||
|
Route::get('capture','capture');
|
||||||
|
});
|
||||||
|
|
||||||
// Account linking to OPENID host
|
// Account linking to OPENID host
|
||||||
Route::get('auth/{socialProvider}',[SocialLoginController::class,'redirectToProvider']);
|
Route::controller(PaypalController::class)
|
||||||
Route::get('auth/{socialProvider}/callback',[SocialLoginController::class,'handleProviderCallback']);
|
->prefix('auth')
|
||||||
Route::get('auth/{socialProvider}/token',[SocialLoginController::class,'handleBearerTokenCallback']);
|
->group(function() {
|
||||||
Route::get('auth/{socialProvider}/link',[SocialLoginController::class,'link']);
|
Route::get('{socialProvider}','redirectToProvider');
|
||||||
Route::post('auth/{socialProvider}/linkcomplete',[SocialLoginController::class,'linkcomplete']);
|
Route::get('{socialProvider}/callback','handleProviderCallback');
|
||||||
|
Route::get('{socialProvider}/token','handleBearerTokenCallback');
|
||||||
|
Route::get('{socialProvider}/link','link');
|
||||||
|
Route::post('{socialProvider}/linkcomplete','linkcomplete');
|
||||||
|
});
|
||||||
|
|
||||||
// Return from user switch
|
// User Switch
|
||||||
Route::get('admin/switch/stop',[SwitchUserController::class,'switch_stop'])
|
Route::controller(SwitchUserController::class)
|
||||||
|
->prefix('switch')
|
||||||
->middleware('auth')
|
->middleware('auth')
|
||||||
->name('switch.stop');
|
->group(function() {
|
||||||
|
Route::get('stop','switch_stop');
|
||||||
|
Route::get('start/{user}','switch_start')
|
||||||
|
->middleware(['role:reseller','can:assume,user']);
|
||||||
|
});
|
||||||
|
|
||||||
// Our Admin Routes - for wholesalers
|
// Our Admin Routes - for wholesalers
|
||||||
Route::group(['middleware'=>['auth','role:wholesaler'],'prefix'=>'a'],function() {
|
Route::group(['middleware'=>['auth','role:wholesaler'],'prefix'=>'a'],function() {
|
||||||
@ -137,11 +150,6 @@ Route::group(['middleware'=>['auth','role:wholesaler'],'prefix'=>'a'],function()
|
|||||||
|
|
||||||
// Our Reseller Routes
|
// Our Reseller Routes
|
||||||
Route::group(['middleware'=>['auth','role:reseller'],'prefix'=>'r'],function() {
|
Route::group(['middleware'=>['auth','role:reseller'],'prefix'=>'r'],function() {
|
||||||
// Enable user switch
|
|
||||||
Route::get('switch/start/{user}',[SwitchUserController::class,'switch_start'])
|
|
||||||
->middleware('can:assume,user')
|
|
||||||
->name('switch.start');
|
|
||||||
|
|
||||||
// Reseller Reports
|
// Reseller Reports
|
||||||
Route::group(['prefix'=>'report'],function() {
|
Route::group(['prefix'=>'report'],function() {
|
||||||
Route::view('charge/pending','theme.backend.adminlte.charge.pending');
|
Route::view('charge/pending','theme.backend.adminlte.charge.pending');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user