Proyectos de Subversion Moodle

Rev

Autoría | Ultima modificación | Ver Log |

{"version":3,"file":"oauth2callback.min.js","sources":["../../src/moodlenet/oauth2callback.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * A module to handle the OAuth2 callback for MoodleNet.\n *\n * @module     core/moodlenet/oauth2callback\n * @copyright  2023 Huong Nguyen <huongnv13@gmail.com>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @since      4.2\n */\n\nimport Prefetch from \"core/prefetch\";\nimport {alert} from 'core/notification';\nimport {getString} from 'core/str';\n\n/**\n * Handle the OAuth2 callback for MoodleNet.\n *\n * @param {String} error Error\n * @param {String} errorDescription Error description\n */\nconst handleCallback = (error, errorDescription) => {\n    if (window.opener) {\n        // Call the MoodleNet Authorization again in the opener window.\n        window.opener.moodleNetAuthorize(error, errorDescription);\n        // Close the authorization popup.\n        // We need to use setTimeout here because the Behat 'I press \"x\" and switch to main window' step expects the popup to still\n        // be visible after clicking the button. Otherwise, it will throw a webdriver error.\n        setTimeout(() => {\n            // Close the authorization popup.\n            window.close();\n        }, 300);\n    } else {\n        alert(getString('error', 'moodle'), getString('moodlenet:sharefailtitle', 'moodle'));\n    }\n};\n\n/**\n * Initialize.\n *\n * @param {String} error Error\n * @param {String} errorDescription Error description\n */\nexport const init = (error, errorDescription) => {\n    Prefetch.prefetchStrings('moodle', ['moodlenet:sharefailtitle', 'error']);\n    handleCallback(error, errorDescription);\n};\n"],"names":["error","errorDescription","prefetchStrings","window","opener","moodleNetAuthorize","setTimeout","close","handleCallback"],"mappings":";;;;;;;;4JAwDoB,CAACA,MAAOC,sCACfC,gBAAgB,SAAU,CAAC,2BAA4B,UAvB7C,EAACF,MAAOC,oBACvBE,OAAOC,QAEPD,OAAOC,OAAOC,mBAAmBL,MAAOC,kBAIxCK,YAAW,KAEPH,OAAOI,UACR,+BAEG,kBAAU,QAAS,WAAW,kBAAU,2BAA4B,YAY9EC,CAAeR,MAAOC"}