<commit_before><?php namespace Octobro\API\Classes;

use Input;
use Event;
use Response;
use Exception;
use Authorizer;
use SimpleXMLElement;
use Illuminate\Routing\Controller;
use RainLab\User\Models\User;
use Symfony\Component\Yaml\Dumper as YamlDumper;
use League\Fractal\Manager;
use League\Fractal\Resource\Collection;
use League\Fractal\Resource\Item;
use League\Fractal\Pagination\IlluminatePaginatorAdapter;

class ApiController extends Controller {

    protected $input, $data;

    protected $user;

	protected $statusCode = 200;

	const CODE_WRONG_ARGS = 'WRONG_ARGS';
    const CODE_NOT_FOUND = 'NOT_FOUND';
    const CODE_INTERNAL_ERROR = 'INTERNAL_ERROR';
    const CODE_UNAUTHORIZED = 'UNAUTHORIZED';
    const CODE_FORBIDDEN = 'FORBIDDEN';
    const CODE_INVALID_MIME_TYPE = 'INVALID_MIME_TYPE';

    public function __construct(Manager $fractal)
    {
        $this->fractal = $fractal;

        // Including data
        if (Input::get('include')) {
            $this->fractal->parseIncludes(Input::get('include'));
        }

        // Excluding data
        if (Input::get('exclude')) {
            $this->fractal->parseExcludes(Input::get('exclude'));
        }

        $this->user = $this->getUser();

        $this->input = request()->isJson() ? request()->json() : request();
        $this->data = $this->input->all();

        $this->fireDebugFilters();
    }

    public function getUser()
    {
        try {
            $userId = Authorizer::getResourceOwnerId();

            if($userId) {
                return User::find($userId);
            }
        } catch(Exception $e) {
            return null;
        }
    }

    public function fireDebugFilters()
    {<commit_msg>Auto Auth::login when user is detected<commit_after><?php namespace Octobro\API\Classes;

use Auth;
use Input;
use Event;
use Response;
use Exception;
use Authorizer;
use SimpleXMLElement;
use Illuminate\Routing\Controller;
use RainLab\User\Models\User;
use Symfony\Component\Yaml\Dumper as YamlDumper;
use League\Fractal\Manager;
use League\Fractal\Resource\Collection;
use League\Fractal\Resource\Item;
use League\Fractal\Pagination\IlluminatePaginatorAdapter;

class ApiController extends Controller {

    protected $input, $data;

    protected $user;

	protected $statusCode = 200;

	const CODE_WRONG_ARGS = 'WRONG_ARGS';
    const CODE_NOT_FOUND = 'NOT_FOUND';
    const CODE_INTERNAL_ERROR = 'INTERNAL_ERROR';
    const CODE_UNAUTHORIZED = 'UNAUTHORIZED';
    const CODE_FORBIDDEN = 'FORBIDDEN';
    const CODE_INVALID_MIME_TYPE = 'INVALID_MIME_TYPE';

    public function __construct(Manager $fractal)
    {
        $this->fractal = $fractal;

        // Including data
        if (Input::get('include')) {
            $this->fractal->parseIncludes(Input::get('include'));
        }

        // Excluding data
        if (Input::get('exclude')) {
            $this->fractal->parseExcludes(Input::get('exclude'));
        }

        $this->user = $this->getUser();

        $this->input = request()->isJson() ? request()->json() : request();
        $this->data = $this->input->all();

        $this->fireDebugFilters();
    }

    public function getUser()
    {
        try {
            $userId = Authorizer::getResourceOwnerId();

            if ($userId) {
                $user = User::find($userId);

                Auth::login($user);

                return $user;
            }
        } catch(Exception $e) {
            return null;
        }
    }

    public function fireDebugFilters()
    {
{'fraction_non_alphanumeric': 0.1279432624113475, 'fraction_numerical': 0.001702127659574468, 'mean_word_length': 2.7312169312169314, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, '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': '2233657', 'n_tokens_mistral': 1120, 'n_tokens_neox': 1085, 'n_words': 215}