Skip to content

Commit

Permalink
internal(helper): make trait to evaluate if request is compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethTrecy committed Oct 3, 2023
1 parent 8ef2718 commit 01e84b4
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions app/Helpers/RequireCompatibleAuthentication.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace App\Helpers;

use CodeIgniter\HTTP\RequestInterface;

trait RequireCompatibleTokenExpiration {
public function hasCompatibleTokenExpirationType(RequestInterface $request): bool {
$current_body = $this->request->getJSON(true);

return
isset($current_body["@meta"])
&& isset($current_body["@meta"]["expiration_type"])
&& count(
array_diff(
SUPPORTED_TOKEN_EXPIRATION_TYPES,
$current_body["@meta"]["expiration_type"]
)
) > 0;
}
}

0 comments on commit 01e84b4

Please sign in to comment.