|
|
@@ -178,8 +178,28 @@ module.exports = function(crowi, app) {
|
|
|
}
|
|
|
|
|
|
actions.externalAccounts.disassociate = function(req, res) {
|
|
|
- // TODO impl
|
|
|
- // TODO check password is set
|
|
|
+
|
|
|
+ const redirectWithFlash = (type, msg) => {
|
|
|
+ req.flash(type, msg);
|
|
|
+ return res.redirect('/me/external-accounts');
|
|
|
+ }
|
|
|
+
|
|
|
+ if (req.body == null) {
|
|
|
+ redirectWithFlash('errorMessage', 'Invalid form.');
|
|
|
+ }
|
|
|
+
|
|
|
+ const providerType = req.body.providerType;
|
|
|
+ const accountId = req.body.accountId;
|
|
|
+ const userData = req.user;
|
|
|
+
|
|
|
+ ExternalAccount.deleteOne({providerType, accountId, user: userData})
|
|
|
+ .then(() => {
|
|
|
+ return redirectWithFlash('successMessage', 'Successfully disassociated.');
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ return redirectWithFlash('errorMessage', err.message);
|
|
|
+ });
|
|
|
+
|
|
|
}
|
|
|
|
|
|
actions.externalAccounts.associateLdap = function(req, res) {
|