|
|
@@ -915,7 +915,7 @@ module.exports = function(crowi, app) {
|
|
|
};
|
|
|
|
|
|
actions.api.securityPassportGoogleSetting = async(req, res) => {
|
|
|
- var form = req.form.settingForm;
|
|
|
+ const form = req.form.settingForm;
|
|
|
|
|
|
if (!req.form.isValid) {
|
|
|
return res.json({status: false, message: req.form.errors.join('\n')});
|
|
|
@@ -929,14 +929,21 @@ module.exports = function(crowi, app) {
|
|
|
await crowi.passportService.resetGoogleStrategy();
|
|
|
// setup strategy
|
|
|
if (Config.isEnabledPassportGoogle(config)) {
|
|
|
- await crowi.passportService.setupGoogleStrategy(true);
|
|
|
+ try {
|
|
|
+ await crowi.passportService.setupGoogleStrategy(true);
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
+ // reset
|
|
|
+ await crowi.passportService.resetGoogleStrategy();
|
|
|
+ return res.json({status: false, message: err.message});
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return res.json({status: true});
|
|
|
};
|
|
|
|
|
|
actions.api.securityPassportGitHubSetting = async(req, res) => {
|
|
|
- var form = req.form.settingForm;
|
|
|
+ const form = req.form.settingForm;
|
|
|
|
|
|
if (!req.form.isValid) {
|
|
|
return res.json({status: false, message: req.form.errors.join('\n')});
|
|
|
@@ -950,14 +957,21 @@ module.exports = function(crowi, app) {
|
|
|
await crowi.passportService.resetGitHubStrategy();
|
|
|
// setup strategy
|
|
|
if (Config.isEnabledPassportGoogle(config)) {
|
|
|
- await crowi.passportService.setupGitHubStrategy(true);
|
|
|
+ try {
|
|
|
+ await crowi.passportService.setupGitHubStrategy(true);
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
+ // reset
|
|
|
+ await crowi.passportService.resetGoogleStrategy();
|
|
|
+ return res.json({status: false, message: err.message});
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return res.json({status: true});
|
|
|
};
|
|
|
|
|
|
actions.api.customizeSetting = function(req, res) {
|
|
|
- var form = req.form.settingForm;
|
|
|
+ const form = req.form.settingForm;
|
|
|
|
|
|
if (req.form.isValid) {
|
|
|
debug('form content', form);
|
|
|
@@ -969,7 +983,7 @@ module.exports = function(crowi, app) {
|
|
|
};
|
|
|
|
|
|
actions.api.customizeSetting = function(req, res) {
|
|
|
- var form = req.form.settingForm;
|
|
|
+ const form = req.form.settingForm;
|
|
|
|
|
|
if (req.form.isValid) {
|
|
|
debug('form content', form);
|