|
|
@@ -564,87 +564,6 @@ module.exports = function(crowi, app) {
|
|
|
|
|
|
actions.api = {};
|
|
|
|
|
|
- actions.api.securityPassportGoogleSetting = async(req, res) => {
|
|
|
- const form = req.form.settingForm;
|
|
|
-
|
|
|
- if (!req.form.isValid) {
|
|
|
- return res.json({ status: false, message: req.form.errors.join('\n') });
|
|
|
- }
|
|
|
-
|
|
|
- debug('form content', form);
|
|
|
- await configManager.updateConfigsInTheSameNamespace('crowi', form);
|
|
|
-
|
|
|
- // reset strategy
|
|
|
- await crowi.passportService.resetGoogleStrategy();
|
|
|
- // setup strategy
|
|
|
- if (configManager.getConfig('crowi', 'security:passport-google:isEnabled')) {
|
|
|
- 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) => {
|
|
|
- const form = req.form.settingForm;
|
|
|
-
|
|
|
- if (!req.form.isValid) {
|
|
|
- return res.json({ status: false, message: req.form.errors.join('\n') });
|
|
|
- }
|
|
|
-
|
|
|
- debug('form content', form);
|
|
|
- await configManager.updateConfigsInTheSameNamespace('crowi', form);
|
|
|
-
|
|
|
- // reset strategy
|
|
|
- await crowi.passportService.resetGitHubStrategy();
|
|
|
- // setup strategy
|
|
|
- if (configManager.getConfig('crowi', 'security:passport-github:isEnabled')) {
|
|
|
- try {
|
|
|
- await crowi.passportService.setupGitHubStrategy(true);
|
|
|
- }
|
|
|
- catch (err) {
|
|
|
- // reset
|
|
|
- await crowi.passportService.resetGitHubStrategy();
|
|
|
- return res.json({ status: false, message: err.message });
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return res.json({ status: true });
|
|
|
- };
|
|
|
-
|
|
|
- actions.api.securityPassportTwitterSetting = async(req, res) => {
|
|
|
- const form = req.form.settingForm;
|
|
|
-
|
|
|
- if (!req.form.isValid) {
|
|
|
- return res.json({ status: false, message: req.form.errors.join('\n') });
|
|
|
- }
|
|
|
-
|
|
|
- debug('form content', form);
|
|
|
- await configManager.updateConfigsInTheSameNamespace('crowi', form);
|
|
|
-
|
|
|
- // reset strategy
|
|
|
- await crowi.passportService.resetTwitterStrategy();
|
|
|
- // setup strategy
|
|
|
- if (configManager.getConfig('crowi', 'security:passport-twitter:isEnabled')) {
|
|
|
- try {
|
|
|
- await crowi.passportService.setupTwitterStrategy(true);
|
|
|
- }
|
|
|
- catch (err) {
|
|
|
- // reset
|
|
|
- await crowi.passportService.resetTwitterStrategy();
|
|
|
- return res.json({ status: false, message: err.message });
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return res.json({ status: true });
|
|
|
- };
|
|
|
-
|
|
|
// app.post('/_api/admin/notifications.add' , admin.api.notificationAdd);
|
|
|
actions.api.notificationAdd = function(req, res) {
|
|
|
const UpdatePost = crowi.model('UpdatePost');
|