Browse Source

refactor(nocodb): revise response messages

pull/5269/head
Wing-Kam Wong 2 years ago
parent
commit
eec05522d9
  1. 22
      packages/nocodb/src/lib/controllers/projectUser.ctl.ts
  2. 8
      packages/nocodb/src/lib/controllers/user/user.ctl.ts
  3. 2
      packages/nocodb/src/lib/v1-legacy/rest/RestAuthCtrl.ts

22
packages/nocodb/src/lib/controllers/projectUser.ctl.ts

@ -13,25 +13,26 @@ async function userList(req, res) {
} }
async function userInvite(req, res): Promise<any> { async function userInvite(req, res): Promise<any> {
res.json(
await projectUserService.userInvite({ await projectUserService.userInvite({
projectId: req.params.projectId, projectId: req.params.projectId,
projectUser: req.body, projectUser: req.body,
req, req,
}) })
); res.json({
msg: 'The user has been invited successfully',
});
} }
// @ts-ignore async function projectUserUpdate(req, res): Promise<any> {
async function projectUserUpdate(req, res, next): Promise<any> {
res.json(
await projectUserService.projectUserUpdate({ await projectUserService.projectUserUpdate({
projectUser: req.body, projectUser: req.body,
projectId: req.params.projectId, projectId: req.params.projectId,
userId: req.params.userId, userId: req.params.userId,
req, req,
}) })
); res.json({
msg: 'The user has been updated successfully',
});
} }
async function projectUserDelete(req, res): Promise<any> { async function projectUserDelete(req, res): Promise<any> {
@ -41,19 +42,22 @@ async function projectUserDelete(req, res): Promise<any> {
req, req,
}); });
res.json({ res.json({
msg: 'success', msg: 'The user has been deleted successfully',
}); });
} }
async function projectUserInviteResend(req, res): Promise<any> { async function projectUserInviteResend(req, res): Promise<any> {
res.json(
await projectUserService.projectUserInviteResend({ await projectUserService.projectUserInviteResend({
projectId: req.params.projectId, projectId: req.params.projectId,
userId: req.params.userId, userId: req.params.userId,
projectUser: req.body, projectUser: req.body,
req, req,
}) })
); ;
res.json({
msg: 'The invitation has been sent to the user'
})
} }
const router = Router({ mergeParams: true }); const router = Router({ mergeParams: true });

8
packages/nocodb/src/lib/controllers/user/user.ctl.ts

@ -131,7 +131,7 @@ async function passwordChange(req: Request<any, any>, res): Promise<any> {
body: req.body, body: req.body,
}); });
res.json({ msg: 'Password updated successfully' }); res.json({ msg: 'Password has been updated successfully' });
} }
async function passwordForgot(req: Request<any, any>, res): Promise<any> { async function passwordForgot(req: Request<any, any>, res): Promise<any> {
@ -148,7 +148,7 @@ async function tokenValidate(req, res): Promise<any> {
await userService.tokenValidate({ await userService.tokenValidate({
token: req.params.tokenId, token: req.params.tokenId,
}); });
res.json(true); res.json({ msg: 'Token has been validated successfully' });
} }
async function passwordReset(req, res): Promise<any> { async function passwordReset(req, res): Promise<any> {
@ -158,7 +158,7 @@ async function passwordReset(req, res): Promise<any> {
req, req,
}); });
res.json({ msg: 'Password reset successful' }); res.json({ msg: 'Password has been reset successfully' });
} }
async function emailVerification(req, res): Promise<any> { async function emailVerification(req, res): Promise<any> {
@ -167,7 +167,7 @@ async function emailVerification(req, res): Promise<any> {
req, req,
}); });
res.json({ msg: 'Email verified successfully' }); res.json({ msg: 'Email has been verified successfully' });
} }
async function renderPasswordReset(req, res): Promise<any> { async function renderPasswordReset(req, res): Promise<any> {

2
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) { } catch (e) {
console.log(e); console.log(e);
next(e); next(e);

Loading…
Cancel
Save