Skip to content

Commit

Permalink
feat: api to reset homeorg
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed Apr 21, 2022
1 parent e4b2647 commit 15e106b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
20 changes: 20 additions & 0 deletions src/controllers/organization.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,26 @@ export const create = async (req, res) => {
}
};

export const resetHomeOrg = async (req, res) => {
try {
await assertIfReadOnlyMode();
await assertDataLayerAvailable();
await assertWalletIsAvailable();
await assertWalletIsSynced();

await Organization.destroy({ where: { isHome: true } });

res.json({
message: 'Your home organization was reset, please create a new one.',
});
} catch (error) {
res.status(400).json({
message: 'Error resetting your organization',
error: error.message,
});
}
};

// eslint-disable-next-line
export const importOrg = async (req, res) => {
try {
Expand Down
14 changes: 7 additions & 7 deletions src/routes/v1/resources/organization.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ OrganizationRouter.post(
},
);

OrganizationRouter.delete('/', (req, res) => {
return OrganizationController.resetHomeOrg(req, res);
});

OrganizationRouter.post('/create', (req, res) => {
return OrganizationController.createV2(req, res);
});
Expand All @@ -42,13 +46,9 @@ OrganizationRouter.put(
},
);

+OrganizationRouter.delete(
'/import',
validator.body(importOrganizationSchema),
(req, res) => {
return OrganizationController.deleteImportedOrg(req, res);
},
);
OrganizationRouter.delete('/import', (req, res) => {
return OrganizationController.deleteImportedOrg(req, res);
});

OrganizationRouter.put(
'/subscribe',
Expand Down

0 comments on commit 15e106b

Please sign in to comment.