<commit_before><?php

namespace ThemeAnorak\LaravelShopify\Middleware;

use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use ThemeAnorak\LaravelShopify\Contracts\ShopifyFactoryContract;

class ShopifyAuthorisation
{
    public function handle(Request $request, Closure $next, ShopifyFactoryContract $factory)
    {
        if (!$request->header('token')) {
            $factory->auth->getAuthorisationUrl(Auth::user());
        }

        return $next($request);

    }

}<commit_msg>auth check added to MW<commit_after><?php

namespace ThemeAnorak\LaravelShopify\Middleware;

use Closure;
use Illuminate\Auth\AuthenticationException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use ThemeAnorak\LaravelShopify\Contracts\ShopifyFactoryContract;

class ShopifyAuthorisation
{
    public function handle(Request $request, Closure $next, ShopifyFactoryContract $factory)
    {
        $user = Auth::user();
        if (!$user) {
            throw new AuthenticationException();
        }

        if (!$request->header('token')) {
            $factory->auth->getAuthorisationUrl(Auth::user());
        }

        return $next($request);

    }

}
{'fraction_non_alphanumeric': 0.11641541038525963, 'fraction_numerical': 0.0, 'mean_word_length': 3.742063492063492, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3616523', 'n_tokens_mistral': 349, 'n_tokens_neox': 350, 'n_words': 65}