Commit 0d6f834b authored by Chenu Denis's avatar Chenu Denis
Browse files

[fix] Redirect when disalow read

[fix] All logout after reloadAnyResponse action
parent a9185699
......@@ -6,7 +6,7 @@
* @copyright 2020-2021 Denis Chenu <http://www.sondages.pro>
* @copyright 2020-2021 OECD <http://www.oecd.org>
* @license AGPL v3
* @version 0.7.1
* @version 0.7.3
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -152,7 +152,11 @@ class OrcidAuthenticate extends PluginBase {
$scope = $this->get('scope',null,null,'authenticate');
$authorizationUrl = $provider->getAuthorizationUrl(['scope'=>'/' . $scope]);
if (!App()->getRequest()->getQuery('code')) {
/* Global system ? Currently : must not : thiw an error */
/* Global system ? Currently : must not : this an error */
if(App()->getRequest()->getQuery('error')) {
$resetSurvey = App()->getController()->createUrl("/survey/index", array("sid" => $surveyId, "newtest" => "Y"));
App()->getController()->redirect($resetSurvey);
}
throw new CHttpException(400,'Must use only for redirect uri');
}
if (!App()->getRequest()->getQuery('state')) {
......@@ -461,15 +465,21 @@ class OrcidAuthenticate extends PluginBase {
if (App()->getRequest()->getParam('action') == 'previewgroup' || App()->getRequest()->getParam('action') == 'previewquestion') {
return;
}
if (App()->getRequest()->getParam('clearall') == 'clearall' && App()->getRequest()->getPost('confirm-clearall')) {
if ( App()->getRequest()->getParam('clearall') == 'clearall' &&
( App()->getRequest()->getPost('confirm-clearall') || App()->getRequest()->getParam('orcid-logout') == 'logout')
) {
App()->session['orcidSurveyTokens'] = null;
App()->session['OrcidToken'] = null;
if (App()->getRequest()->getParam('orcid-logout') == 'logout') {
killSurveySession($iSurveyId);
resetQuestionTimers($iSurveyId);
}
$urlLogout = 'https://orcid.org/userStatus.json?logUserOut=true';
if($this->get('SandBox')) {
$urlLogout = 'https://sandbox.orcid.org/userStatus.json?logUserOut=true';
}
$scriptLogOut = " var orcidLogOutUrl = '{$urlLogout}'\n"
. " orcidLogout();";
$this->registerOrcidPackage();
$scriptLogOut = "orcidLogout('{$urlLogout}');";
App()->getClientScript()->registerScript("orcidScriptLogOut",$scriptLogOut);
return;
}
......@@ -773,8 +783,7 @@ class OrcidAuthenticate extends PluginBase {
if($this->get('SandBox')) {
$urlLogout = 'https://sandbox.orcid.org/userStatus.json?logUserOut=true';
}
$scriptLogOut = " var orcidLogOutUrl = '{$urlLogout}'\n"
. " orcidLogout();";
$scriptLogOut = " orcidLogout('{$urlLogout}');";
App()->getClientScript()->registerScript("orcidScriptLogOut",$scriptLogOut);
return;
}
......
function orcidLogout() {
function orcidLogout(orcidLogOutUrl) {
$.ajax({
url: orcidLogOutUrl,
dataType: 'jsonp',
success: function(result,status,xhr) {
// OK
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment