<commit_before><?php

// Authorization middleware

class AuthMw
{
	private $groups;
	protected $ci;
	
	public function __construct($groups, \Slim\Container $ci)
	{
		$this->groups = $groups;
		$this->ci = $ci;
	}

	public function __invoke($request, $response, $next)
	{
		//$this->ci->logger->addInfo('grupe sa dozvolom: '.json_encode($this->groups));
		if ($request->hasHeader('Authorization')) {
			$user_token = \App\Models\UserTokens::where('token', '=', $request->getHeaderLine('Authorization'))->where('valid_to', '>', date('Y-m-d H:i:s'))->first();
			if ($user_token) {
				if (\App\Models\Users::isUserInGroup($user_token->user_id, $this->groups)) {
					return $next($request, $response);
				}
			}
		}		
		return $response->withJson(['status'=>'AUTH ERROR', 'message'=>'unauthorized access']);
	}
}<commit_msg>check token fix<commit_after><?php

// Authorization middleware

class AuthMw
{
	private $groups;
	protected $ci;
	
	public function __construct($groups, \Slim\Container $ci)
	{
		$this->groups = $groups;
		$this->ci = $ci;
	}

	public function __invoke($request, $response, $next)
	{
		if ($request->hasHeader('Authorization')) {
			$user_token = \App\Models\UserTokens::where('token', '=', $request->getHeader('Authorization'))->where('valid_to', '>', date('Y-m-d H:i:s'))->first();
			//$this->ci->logger->addDebug('Authorization', $request->getHeader('Authorization'));
			if ($user_token) {
				if (\App\Models\Users::isUserInGroup($user_token->user_id, $this->groups)) {
					return $next($request, $response);
				}
			}
		}		
		return $response->withJson(['status'=>'AUTH ERROR', 'message'=>'unauthorized access']);
	}
}
{'fraction_non_alphanumeric': 0.21017565112053302, 'fraction_numerical': 0.0, 'mean_word_length': 4.837455830388692, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, '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': '4509669', 'n_tokens_mistral': 608, 'n_tokens_neox': 569, 'n_words': 94}