Skip to content

Commit

Permalink
Merge pull request #10 from halkyon/auth-message-form
Browse files Browse the repository at this point in the history
Show message about logging in to access the client for context.
  • Loading branch information
IanSimpson authored Oct 9, 2018
2 parents ca5c459 + af9604d commit 841c4e2
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions code/OAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ class OauthServerController extends \Controller
private $myResponseAdapter;
private $myRepositories;

/**
* @var Authenticator classes on which to show an athentication greeting message.
* @config
*/
private static $authenticator_classes = [
'MemberAuthenticator',
];

private static $allowed_actions = array(
'authorize',
'accessToken',
Expand Down Expand Up @@ -113,6 +121,18 @@ public function authorize()
if (! \Member::currentUserID()) {
// You will probably want to redirect the user at this point to a login endpoint.

foreach ($this->config()->authenticator_classes as $authClass) {
$form = call_user_func([$authClass, 'get_login_form'], $this);
$form->sessionMessage(
_t(
'OAuth.AUTHENTICATE_MESSAGE',
'Please log in to access {originatingSite}.',
['originatingSite' => $authRequest->getClient()->ClientName]
),
'good'
);
}

return $this->redirect(
\Config::inst()->get('Security', 'login_url')
. "?BackURL=" . urlencode($_SERVER['REQUEST_URI'])
Expand Down

0 comments on commit 841c4e2

Please sign in to comment.