Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Commit

Permalink
exception: add attributes to email not found
Browse files Browse the repository at this point in the history
Ref: #126
  • Loading branch information
wellingguzman committed May 11, 2018
1 parent 5e1ccaf commit 09e0434
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class UserWithEmailNotFoundException extends NotFoundException

public function __construct($email)
{
$this->attributes['email'] = $email;
$message = sprintf('User with email "%s" not found', $email);

parent::__construct($message, static::ERROR_CODE);
Expand Down
12 changes: 12 additions & 0 deletions src/core/Directus/Exception/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class Exception extends \Exception
{
const ERROR_CODE = 0;

protected $attributes = [];

/**
* Allows child class to extend the error code value method
*
Expand All @@ -15,4 +17,14 @@ public function getErrorCode()
{
return static::ERROR_CODE;
}

/**
* Gets the error attributes
*
* @return array
*/
public function getAttributes()
{
return $this->attributes;
}
}
8 changes: 7 additions & 1 deletion src/endpoints/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Directus\Application\Http\Request;
use Directus\Application\Http\Response;
use Directus\Application\Route;
use Directus\Authentication\Exception\UserWithEmailNotFoundException;
use Directus\Authentication\Sso\Social;
use Directus\Services\AuthService;
use Directus\Session\Session;
Expand Down Expand Up @@ -220,7 +221,12 @@ public function ssoServiceCallback(Request $request, Response $response)
throw $e;
}

$urlParams['error'] = $e->getMessage();
if ($e instanceof UserWithEmailNotFoundException) {
$urlParams['attributes'] = $e->getAttributes();
}

$urlParams['errorCode'] = $e->getErrorCode();
$urlParams['error'] = true;
}

if ($redirectUrl) {
Expand Down

0 comments on commit 09e0434

Please sign in to comment.