Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion auth-oauth2/oauth2.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function __construct($config, $provider=null) {
}

function callback($resp, $ref=null) {
//TODO: Log any errors to system logs
global $ost;
try {
if ($this->getState() == $resp['state']
&& ($token=$this->provider->getToken($resp['code']))
Expand All @@ -97,9 +97,26 @@ function callback($resp, $ref=null) {
// desired panel
if ($this->login($result, $this))
$this->onSignIn();
} elseif ($ost) {
$ost->logWarning(sprintf('%s: Sign In Failed',
$this->getServiceName()),
'The identity provider returned valid attributes, '
.'but no local account could be matched or '
.'auto-registered for them.', false);
}
} elseif ($ost) {
$ost->logWarning(sprintf('%s: OAuth2 Callback Failed',
$this->getServiceName()),
'The OAuth2 callback did not complete: the state '
.'parameter did not match, or the identity provider '
.'did not return a usable access token / owner '
.'attributes (e.g. invalid_client, invalid_grant, or '
.'an expired authorization code).', false);
}
} catch (Exception $ex) {
if ($ost)
$ost->logError(sprintf('%s: OAuth2 Authentication Error',
$this->getServiceName()), $ex->getMessage(), false);
return false;
}
}
Expand Down