From 50d14baa8b3134992c196dd0f382e51a3197a0df Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sat, 9 May 2020 14:54:55 -0400 Subject: [PATCH] Add docs for #373 --- docs/en/identifiers.rst | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/docs/en/identifiers.rst b/docs/en/identifiers.rst index 90c08720..a79c0307 100644 --- a/docs/en/identifiers.rst +++ b/docs/en/identifiers.rst @@ -104,6 +104,41 @@ Configuration options: required to pass a valid callback to this option to use the authenticator. +Callback identifiers can either return ``null|ArrayAccess`` for simple results, +or an ``Authentication\Authenticator\Result`` if you want to forward error +messages:: + + // A simple callback identifier + $authenticationService->loadIdentifier('Authentication.Identifier', [ + 'callback' => function($data) { + // do identifier logic + + // Return an array of the identified user or null for failure. + if ($result) { + return $result; + } + + return null; + } + ]); + + // Using a result object to return error messages. + $authenticationService->loadIdentifier('Authentication.Identifier', [ + 'callback' => function($data) { + // do identifier logic + + if ($result) { + return new Result($result, Result::SUCCESS); + } + + return new Result( + null, + Result::FAILURE_OTHER, + ['message' => 'Removed user.'] + ); + } + ]); + Identity resolvers ==================