|
|
|
|
@ -5,37 +5,41 @@ require_once __DIR__.'/functions.inc.php'; |
|
|
|
|
|
|
|
|
|
/** @var array $uData */ |
|
|
|
|
|
|
|
|
|
$plugin = AzureActiveDirectory::create(); |
|
|
|
|
if ($uData['auth_source'] === 'azure') { |
|
|
|
|
$plugin = AzureActiveDirectory::create(); |
|
|
|
|
|
|
|
|
|
if ('true' !== $plugin->get(AzureActiveDirectory::SETTING_ENABLE)) { |
|
|
|
|
api_not_allowed(true); |
|
|
|
|
} |
|
|
|
|
if ('true' !== $plugin->get(AzureActiveDirectory::SETTING_ENABLE)) { |
|
|
|
|
api_not_allowed(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$azureIdField = new ExtraFieldValue('user'); |
|
|
|
|
$azureIdValue = $azureIdField->get_values_by_handler_and_field_variable( |
|
|
|
|
$uData['user_id'], |
|
|
|
|
AzureActiveDirectory::EXTRA_FIELD_AZURE_ID |
|
|
|
|
); |
|
|
|
|
$azureIdField = new ExtraFieldValue('user'); |
|
|
|
|
$azureIdValue = $azureIdField->get_values_by_handler_and_field_variable( |
|
|
|
|
$uData['user_id'], |
|
|
|
|
AzureActiveDirectory::EXTRA_FIELD_AZURE_ID |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (empty($azureIdValue) || empty($azureIdValue['value'])) { |
|
|
|
|
api_not_allowed(true); |
|
|
|
|
} |
|
|
|
|
if (empty($azureIdValue) || empty($azureIdValue['value'])) { |
|
|
|
|
api_not_allowed(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$organsationEmailField = new ExtraFieldValue('user'); |
|
|
|
|
$organsationEmailValue = $organsationEmailField->get_values_by_handler_and_field_variable( |
|
|
|
|
$uData['user_id'], |
|
|
|
|
AzureActiveDirectory::EXTRA_FIELD_ORGANISATION_EMAIL |
|
|
|
|
); |
|
|
|
|
$organsationEmailField = new ExtraFieldValue('user'); |
|
|
|
|
$organsationEmailValue = $organsationEmailField->get_values_by_handler_and_field_variable( |
|
|
|
|
$uData['user_id'], |
|
|
|
|
AzureActiveDirectory::EXTRA_FIELD_ORGANISATION_EMAIL |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (empty($organsationEmailValue) || empty($organsationEmailValue['value'])) { |
|
|
|
|
api_not_allowed(true); |
|
|
|
|
} |
|
|
|
|
if (empty($organsationEmailValue) || empty($organsationEmailValue['value'])) { |
|
|
|
|
api_not_allowed(true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$provider = $plugin->getProvider(); |
|
|
|
|
$provider = $plugin->getProvider(); |
|
|
|
|
|
|
|
|
|
$authUrl = $provider->getAuthorizationUrl(['login_hint' => $organsationEmailValue['value']]); |
|
|
|
|
$authUrl = $provider->getAuthorizationUrl(['login_hint' => $organsationEmailValue['value']]); |
|
|
|
|
|
|
|
|
|
ChamiloSession::write('oauth2state', $provider->getState()); |
|
|
|
|
ChamiloSession::write('oauth2state', $provider->getState()); |
|
|
|
|
|
|
|
|
|
header('Location: '.$authUrl); |
|
|
|
|
exit; |
|
|
|
|
// Redirect to Azure login. |
|
|
|
|
header('Location: '.$authUrl); |
|
|
|
|
// Avoid execution from here in local.inc.php script. |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
|
|