From 319a20b473eff60b00fe6e30a99c2bb9fa38a20e Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Thu, 11 Jan 2024 02:12:54 -0700 Subject: [PATCH] Update ParentalControlsController, redirect to new custom error page on active session when attempting to use child invite link so as to not overwrite parent active session with child session --- app/Http/Controllers/ParentalControlsController.php | 13 +++++++++++++ resources/views/errors/custom.blade.php | 10 ++++++++++ 2 files changed, 23 insertions(+) create mode 100644 resources/views/errors/custom.blade.php diff --git a/app/Http/Controllers/ParentalControlsController.php b/app/Http/Controllers/ParentalControlsController.php index 5c60cfae2..1dc2f578f 100644 --- a/app/Http/Controllers/ParentalControlsController.php +++ b/app/Http/Controllers/ParentalControlsController.php @@ -87,7 +87,14 @@ class ParentalControlsController extends Controller public function inviteRegister(Request $request, $id, $code) { + if($request->user()) { + $title = 'You cannot complete this action on this device.'; + $body = 'Please log out or use a different device or browser to complete the invitation registration.'; + return view('errors.custom', compact('title', 'body')); + } + $this->authPreflight($request, true, false); + $pc = ParentalControls::whereRaw('verify_code = BINARY ?', $code)->whereNull(['email_verified_at', 'child_id'])->findOrFail($id); abort_unless(User::whereId($pc->parent_id)->exists(), 404); return view('settings.parental-controls.invite-register-form', compact('pc')); @@ -95,6 +102,12 @@ class ParentalControlsController extends Controller public function inviteRegisterStore(Request $request, $id, $code) { + if($request->user()) { + $title = 'You cannot complete this action on this device.'; + $body = 'Please log out or use a different device or browser to complete the invitation registration.'; + return view('errors.custom', compact('title', 'body')); + } + $this->authPreflight($request, true, false); $pc = ParentalControls::whereRaw('verify_code = BINARY ?', $code)->whereNull('email_verified_at')->findOrFail($id); diff --git a/resources/views/errors/custom.blade.php b/resources/views/errors/custom.blade.php new file mode 100644 index 000000000..932292b6b --- /dev/null +++ b/resources/views/errors/custom.blade.php @@ -0,0 +1,10 @@ +@extends('layouts.app') + +@section('content') +
+
+

{!! $title ?? config('instance.page.404.header')!!}

+

{!! $body ?? config('instance.page.404.body')!!}

+
+
+@endsection