Example #1
0
 public function check($authorization_input)
 {
     try {
         list($this->auth_name, $this->auth_key) = \RTMatt\MonthlyService\Helpers\RTBasicAuthorizationParser::create($authorization_input)->getParsedValues();
     } catch (\Exception $e) {
         return false;
     }
     $this->getKeysByName();
     return $this->checkForValidKey();
 }
 public function getServicesSummary(Request $request)
 {
     $authorization = $request->header('authorization');
     list($auth_name, $auth_key) = \RTMatt\MonthlyService\Helpers\RTBasicAuthorizationParser::create($authorization)->getParsedValues();
     $client = Client::getByAPIName($auth_name);
     if (!$client) {
         return response('Unable to find client data for supplied API key', 404);
     }
     if (!$client->hasActivePlan()) {
         return response("Owner of API key does not have an active plan", 204);
     }
     $report = $client->getServiceReport();
     if ($report->last_backup instanceof Carbon) {
         $report->last_backup = $report->last_backup->diffForHumans();
     }
     return json_encode($report);
 }
Example #3
0
 public static function getFromAuth($auth_header)
 {
     $parsed_auth = \RTMatt\MonthlyService\Helpers\RTBasicAuthorizationParser::create($auth_header);
     $auth_name = $parsed_auth->auth_name;
     return static::getByAPIName($auth_name);
 }