diff --git a/src/core/Directus/Authentication/Exception/UserWithEmailNotFoundException.php b/src/core/Directus/Authentication/Exception/UserWithEmailNotFoundException.php index 4468ed0d30..ba8362918a 100644 --- a/src/core/Directus/Authentication/Exception/UserWithEmailNotFoundException.php +++ b/src/core/Directus/Authentication/Exception/UserWithEmailNotFoundException.php @@ -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); diff --git a/src/core/Directus/Exception/Exception.php b/src/core/Directus/Exception/Exception.php index 7647305d31..2113dc09f6 100644 --- a/src/core/Directus/Exception/Exception.php +++ b/src/core/Directus/Exception/Exception.php @@ -6,6 +6,8 @@ class Exception extends \Exception { const ERROR_CODE = 0; + protected $attributes = []; + /** * Allows child class to extend the error code value method * @@ -15,4 +17,14 @@ public function getErrorCode() { return static::ERROR_CODE; } + + /** + * Gets the error attributes + * + * @return array + */ + public function getAttributes() + { + return $this->attributes; + } } diff --git a/src/endpoints/Auth.php b/src/endpoints/Auth.php index d896d61578..b650c376ee 100644 --- a/src/endpoints/Auth.php +++ b/src/endpoints/Auth.php @@ -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; @@ -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) {