Skip to content

Commit

Permalink
change authorized request
Browse files Browse the repository at this point in the history
  • Loading branch information
daycry committed Jun 30, 2023
1 parent 8781891 commit 757baf1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Exceptions/AuthenticationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

class AuthenticationException extends RuntimeException
{
public static $authorized = true;

protected $code = 403;

/**
Expand All @@ -30,16 +32,19 @@ public static function forUnknownUserProvider(): self

public static function forInvalidCredentials(): self
{
self::$authorized = false;
return new self(lang('RestFul.invalidCredentials'));
}

public static function forNoPassword(): self
{
self::$authorized = false;
return new self(lang('RestFul.noPassword'));
}

public static function forInvalidAccessToken(): self
{
self::$authorized = false;
return new self(lang('RestFul.invalidAccessToken'));
}

Expand Down
4 changes: 4 additions & 0 deletions src/Exceptions/ValidationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@

class ValidationException extends RuntimeException
{
public static $authorized = true;

public static function validationtMethodParamsError($param)
{
self::$authorized = false;
$parser = \Config\Services::parser();
return new self($parser->setData(array( 'param' => $param ))->renderString(lang('RestFul.invalidParamsForMethod')));
}

public static function validationData()
{
self::$authorized = false;
return new self('');
}
}
1 change: 1 addition & 0 deletions src/RestFul.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public function initController(RequestInterface $request, ResponseInterface $res
*/
public function __destruct()
{
log_message('error', 'hhhhh');
if ($this->request) {
$this->_logRequest();

Expand Down

0 comments on commit 757baf1

Please sign in to comment.