<commit_before><?php

namespace App\Http\Middleware;

use App\Models\Account;
use App\Models\Customer;
use Closure;
use Illuminate\Support\Facades\Cache;

class VerifyApiSign
{
    protected $except = [
        '/wechat/customer/login',
        'file/*',
        '/wechat/notify/*'
    ];

    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if($this->inExceptArray($request)){
            return $next($request);
        }

        $token = $request->input('token', '');
//        if (empty($token))
//            return $this->fail(401, '令牌不能为空');
//
//        if (!Cache::has($token))
//            return $this->fail(403, '令牌不存在或者已失效');
//        if (!empty($token)) {
//            $customer_id = Cache::get($token);
//            if(!empty($customer_id) && $customer_id > 0)
//            {
//                $request->customer = Customer::find($customer_id);
//            }
//        }
        $request->customer = Customer::find(85);
        return $next($request);
    }

    protected function fail($code, $msg)
    {
        return response()->json([
            'result_code' => $code,
            'result_msg' => $msg
        ]);
    }

    protected function inExceptArray($request)
    {
        foreach ($this->except as $except) {
            if ($except !== '/') {
                $except = trim($except, '/');
            }

            if ($request->is($except)) {
                return true;
            }
        }
        return false;
    }
}<commit_msg>bug fix<commit_after><?php

namespace App\Http\Middleware;

use App\Models\Account;
use App\Models\Customer;
use Closure;
use Illuminate\Support\Facades\Cache;

class VerifyApiSign
{
    protected $except = [
        '/wechat/customer/login',
        'file/*',
        '/wechat/notify/*'
    ];

    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if($this->inExceptArray($request)){
            return $next($request);
        }

        $token = $request->input('token', '');
//        if (empty($token))
//            return $this->fail(401, '令牌不能为空');
//
//        if (!Cache::has($token))
//            return $this->fail(403, '令牌不存在或者已失效');
        if (!empty($token)) {
            $customer_id = Cache::get($token);
            if(!empty($customer_id) && $customer_id > 0)
            {
                $request->customer = Customer::find($customer_id);
            }
        }
//        $request->customer = Customer::find(85);
        return $next($request);
    }

    protected function fail($code, $msg)
    {
        return response()->json([
            'result_code' => $code,
            'result_msg' => $msg
        ]);
    }

    protected function inExceptArray($request)
    {
        foreach ($this->except as $except) {
            if ($except !== '/') {
                $except = trim($except, '/');
            }

            if ($request->is($except)) {
                return true;
            }
        }
        return false;
    }
}
{'fraction_non_alphanumeric': 0.16534954407294833, 'fraction_numerical': 0.00547112462006079, 'mean_word_length': 1.6712662337662338, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '6523722', 'n_tokens_mistral': 1002, 'n_tokens_neox': 992, 'n_words': 181}