From eec05522d96d60f8eace7440de0682718fbb9d2c Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Sat, 11 Mar 2023 14:31:05 +0800 Subject: [PATCH] refactor(nocodb): revise response messages --- .../src/lib/controllers/projectUser.ctl.ts | 56 ++++++++++--------- .../src/lib/controllers/user/user.ctl.ts | 8 +-- .../src/lib/v1-legacy/rest/RestAuthCtrl.ts | 2 +- 3 files changed, 35 insertions(+), 31 deletions(-) diff --git a/packages/nocodb/src/lib/controllers/projectUser.ctl.ts b/packages/nocodb/src/lib/controllers/projectUser.ctl.ts index cc3beca1f5..1166f7a6d5 100644 --- a/packages/nocodb/src/lib/controllers/projectUser.ctl.ts +++ b/packages/nocodb/src/lib/controllers/projectUser.ctl.ts @@ -13,25 +13,26 @@ async function userList(req, res) { } async function userInvite(req, res): Promise { - res.json( - await projectUserService.userInvite({ - projectId: req.params.projectId, - projectUser: req.body, - req, - }) - ); + await projectUserService.userInvite({ + projectId: req.params.projectId, + projectUser: req.body, + req, + }) + res.json({ + msg: 'The user has been invited successfully', + }); } -// @ts-ignore -async function projectUserUpdate(req, res, next): Promise { - res.json( - await projectUserService.projectUserUpdate({ - projectUser: req.body, - projectId: req.params.projectId, - userId: req.params.userId, - req, - }) - ); +async function projectUserUpdate(req, res): Promise { + await projectUserService.projectUserUpdate({ + projectUser: req.body, + projectId: req.params.projectId, + userId: req.params.userId, + req, + }) + res.json({ + msg: 'The user has been updated successfully', + }); } async function projectUserDelete(req, res): Promise { @@ -41,19 +42,22 @@ async function projectUserDelete(req, res): Promise { req, }); res.json({ - msg: 'success', + msg: 'The user has been deleted successfully', }); } async function projectUserInviteResend(req, res): Promise { - res.json( - await projectUserService.projectUserInviteResend({ - projectId: req.params.projectId, - userId: req.params.userId, - projectUser: req.body, - req, - }) - ); + await projectUserService.projectUserInviteResend({ + projectId: req.params.projectId, + userId: req.params.userId, + projectUser: req.body, + req, + }) +; + res.json({ + msg: 'The invitation has been sent to the user' + }) + } const router = Router({ mergeParams: true }); diff --git a/packages/nocodb/src/lib/controllers/user/user.ctl.ts b/packages/nocodb/src/lib/controllers/user/user.ctl.ts index 84d108e2e5..b411db0e39 100644 --- a/packages/nocodb/src/lib/controllers/user/user.ctl.ts +++ b/packages/nocodb/src/lib/controllers/user/user.ctl.ts @@ -131,7 +131,7 @@ async function passwordChange(req: Request, res): Promise { body: req.body, }); - res.json({ msg: 'Password updated successfully' }); + res.json({ msg: 'Password has been updated successfully' }); } async function passwordForgot(req: Request, res): Promise { @@ -148,7 +148,7 @@ async function tokenValidate(req, res): Promise { await userService.tokenValidate({ token: req.params.tokenId, }); - res.json(true); + res.json({ msg: 'Token has been validated successfully' }); } async function passwordReset(req, res): Promise { @@ -158,7 +158,7 @@ async function passwordReset(req, res): Promise { req, }); - res.json({ msg: 'Password reset successful' }); + res.json({ msg: 'Password has been reset successfully' }); } async function emailVerification(req, res): Promise { @@ -167,7 +167,7 @@ async function emailVerification(req, res): Promise { req, }); - res.json({ msg: 'Email verified successfully' }); + res.json({ msg: 'Email has been verified successfully' }); } async function renderPasswordReset(req, res): Promise { diff --git a/packages/nocodb/src/lib/v1-legacy/rest/RestAuthCtrl.ts b/packages/nocodb/src/lib/v1-legacy/rest/RestAuthCtrl.ts index f150bb1887..6ec37bc4ab 100644 --- a/packages/nocodb/src/lib/v1-legacy/rest/RestAuthCtrl.ts +++ b/packages/nocodb/src/lib/v1-legacy/rest/RestAuthCtrl.ts @@ -1020,7 +1020,7 @@ export default class RestAuthCtrl { }); } - res.json({ msg: 'Success' }); + res.json({ msg: 'Signed out successfully' }); } catch (e) { console.log(e); next(e);