in classes/loginflow/authcode.php [101:139]
public function handleredirect() {
global $CFG, $SESSION;
$state = $this->getoidcparam('state');
$code = $this->getoidcparam('code');
$promptlogin = (bool)optional_param('promptlogin', 0, PARAM_BOOL);
$promptaconsent = (bool)optional_param('promptaconsent', 0, PARAM_BOOL);
$justauth = (bool)optional_param('justauth', 0, PARAM_BOOL);
if (!empty($state)) {
$requestparams = [
'state' => $state,
'code' => $code,
'error_description' => optional_param('error_description', '', PARAM_TEXT),
];
// Response from OP.
$this->handleauthresponse($requestparams);
} else {
if (isloggedin() && !isguestuser() && empty($justauth) && empty($promptaconsent)) {
if (isset($SESSION->wantsurl) and (strpos($SESSION->wantsurl, $CFG->wwwroot) === 0)) {
$urltogo = $SESSION->wantsurl;
unset($SESSION->wantsurl);
} else {
$urltogo = new \moodle_url('/');
}
redirect($urltogo);
die();
}
// Initial login request.
$stateparams = ['forceflow' => 'authcode'];
$extraparams = [];
if ($promptaconsent === true) {
$extraparams = ['prompt' => 'admin_consent'];
}
if ($justauth === true) {
$stateparams['justauth'] = true;
}
$this->initiateauthrequest($promptlogin, $stateparams, $extraparams);
}
}