Appsumo fix
This commit is contained in:
parent
edfca49b7e
commit
2ffc5311f9
|
@ -39,16 +39,10 @@ class Handler extends ExceptionHandler
|
|||
|
||||
/**
|
||||
* Convert an authentication exception into a response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Illuminate\Auth\AuthenticationException $exception
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
protected function unauthenticated($request, AuthenticationException $exception)
|
||||
{
|
||||
return $request->expectsJson()
|
||||
? response()->json(['message' => $exception->getMessage()], 401)
|
||||
: redirect(front_url('login'));
|
||||
return response()->json(['message' => $exception->getMessage()], 401);
|
||||
}
|
||||
|
||||
public function report(Throwable $exception)
|
||||
|
|
|
@ -17,10 +17,10 @@ class AppSumoAuthController extends Controller
|
|||
|
||||
public function handleCallback(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'code' => 'required',
|
||||
]);
|
||||
$accessToken = $this->retrieveAccessToken($request->code);
|
||||
if (!$code = $request->code) {
|
||||
return response()->json(['message' => 'Healthy'], 200);
|
||||
}
|
||||
$accessToken = $this->retrieveAccessToken($code);
|
||||
$license = $this->fetchOrCreateLicense($accessToken);
|
||||
|
||||
// If user connected, attach license
|
||||
|
|
|
@ -30,7 +30,6 @@ class FormSubmissionController extends Controller
|
|||
public function export(string $id)
|
||||
{
|
||||
$form = Form::findOrFail((int) $id);
|
||||
$this->authorize('view', $form);
|
||||
|
||||
$allRows = [];
|
||||
foreach ($form->submissions->toArray() as $row) {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Http;
|
||||
|
||||
use App\Http\Middleware\AcceptsJsonMiddleware;
|
||||
use App\Http\Middleware\AuthenticateJWT;
|
||||
use App\Http\Middleware\CustomDomainRestriction;
|
||||
use App\Http\Middleware\IsAdmin;
|
||||
|
@ -29,6 +30,7 @@ class Kernel extends HttpKernel
|
|||
\App\Http\Middleware\SetLocale::class,
|
||||
AuthenticateJWT::class,
|
||||
CustomDomainRestriction::class,
|
||||
AcceptsJsonMiddleware::class
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AcceptsJsonMiddleware
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
|
||||
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
$request->headers->set('Accept', 'application/json');
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
|
@ -24,27 +24,26 @@ export default defineNuxtRouteMiddleware((to, from) => {
|
|||
|
||||
const customDomainHeaderValue = useRequestHeaders()[customDomainHeaderName]
|
||||
if (!customDomainHeaderValue || customDomainHeaderValue !== getDomain(getHost())) {
|
||||
// If custom domain header doesn't match, redirect
|
||||
console.error('Custom domain header does not match, redirecting',{
|
||||
'customDomainHeaderValue': customDomainHeaderValue,
|
||||
'host': getDomain(getHost()),
|
||||
})
|
||||
return redirectToMainDomain('header_mismatch', {
|
||||
customDomainHeaderValue,
|
||||
return redirectToMainDomain( {
|
||||
reason: 'header_mismatch',
|
||||
customDomainHeaderValue: customDomainHeaderValue,
|
||||
host: getDomain(getHost()),
|
||||
})
|
||||
}
|
||||
|
||||
if (!config.public.customDomainsEnabled) {
|
||||
// If custom domain not allowed, redirect
|
||||
return redirectToMainDomain('custom_domains_disabled')
|
||||
return redirectToMainDomain({
|
||||
reason: 'custom_domains_disabled'
|
||||
})
|
||||
}
|
||||
|
||||
if (!customDomainAllowedRoutes.includes(to.name)) {
|
||||
// Custom domain only allowed for form url
|
||||
return redirectToMainDomain('route_not_allowed', {
|
||||
return redirectToMainDomain({
|
||||
reason: 'route_not_allowed',
|
||||
route: to.name,
|
||||
customDomainAllowedRoutes
|
||||
customDomainAllowedRoutes: customDomainAllowedRoutes
|
||||
})
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue