Browse Source

fix: Add project name and correct role in invite

related #287

Signed-off-by: Pranav C Balan <pranavxc@gmail.com>
pull/293/head
Pranav C Balan 3 years ago
parent
commit
15933af443
  1. 19
      packages/nc-gui/components/auth/userManagement.vue
  2. 18
      packages/nocodb/src/lib/noco/rest/RestAuthCtrl.ts
  3. 2
      packages/nocodb/src/lib/noco/rest/ui/emailTemplates/invite.ts

19
packages/nc-gui/components/auth/userManagement.vue

@ -536,9 +536,14 @@ export default {
},
async rensendInvite(id) {
try {
await this.$axios.post('/admin/resendInvite/' + id, null, {
await this.$axios.post('/admin/resendInvite/' + id, {
projectName: this.$store.getters['project/GtrProjectName'],
}, {
headers: {
'xc-auth': this.$store.state.users.token
},
params: {
project_id: this.$route.params.project_id
}
});
this.$toast.success('Invite email sent successfully').goAway(3000);
@ -620,7 +625,11 @@ export default {
},
async inviteUser(email) {
try {
await this.$axios.post('/admin', {email, project_id: this.$route.params.project_id}, {
await this.$axios.post('/admin', {
email,
project_id: this.$route.params.project_id,
projectName: this.$store.getters['project/GtrProjectName']
}, {
headers: {
'xc-auth': this.$store.state.users.token
}
@ -646,7 +655,8 @@ export default {
await this.$axios.put('/admin/' + this.selectedUser.id, {
roles: this.selectedUser.roles,
email: this.selectedUser.email,
project_id: this.$route.params.project_id
project_id: this.$route.params.project_id,
projectName: this.$store.getters['project/GtrProjectName']
}, {
headers: {
'xc-auth': this.$store.state.users.token
@ -655,7 +665,8 @@ export default {
} else {
data = await this.$axios.post('/admin', {
...this.selectedUser,
project_id: this.$route.params.project_id
project_id: this.$route.params.project_id,
projectName: this.$store.getters['project/GtrProjectName']
}, {
headers: {
'xc-auth': this.$store.state.users.token

18
packages/nocodb/src/lib/noco/rest/RestAuthCtrl.ts

@ -541,12 +541,13 @@ export default class RestAuthCtrl {
res.json({
token: jwt.sign({
email: user.email,
firstname: user.firstname,
lastname: user.lastname,
id: user.id,
roles: user.roles
}, this.config.auth.jwt.secret, this.config.auth.jwt.options)
email: user.email,
firstname: user.firstname,
lastname: user.lastname,
id: user.id,
roles: user.roles
}, this.config.auth.jwt.secret,
this.config.auth.jwt.options)
} as any);
} catch (e) {
console.log(e);
@ -1168,6 +1169,7 @@ export default class RestAuthCtrl {
return next(new Error(`User with id '${req.params.id}' not found`));
}
req.body.roles = user.roles;
const invite_token = uuidv4();
await this.users.update({
@ -1197,13 +1199,13 @@ export default class RestAuthCtrl {
const template = (await import('./ui/emailTemplates/invite')).default;
if (this.emailClient) {
await this.emailClient.mailSend({
to: email,
subject: "Verify email",
html: ejs.render(template, {
signupLink: `${req.ncSiteUrl}${this.config?.dashboardPath}#/user/authentication/signup/${token}`,
projectName: req.body.projectName,
projectName: req.body?.projectName,
roles: (req.body?.roles || '').split(',').map(r => r.replace(/^./, m => m.toUpperCase())).join(', '),
adminEmail: req.session?.passport?.user?.email
})
})

2
packages/nocodb/src/lib/noco/rest/ui/emailTemplates/invite.ts

@ -132,7 +132,7 @@ export default `<!doctype html>
<p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; margin-bottom: 15px;">
Hi,</p>
<p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; margin-bottom: 15px;">
I invited you to be an Admin of the NocoDB project <%- projectName %>".
I invited you to be "<%- roles -%>" of the NocoDB project "<%- projectName %>".
Click the button below to to accept my invitation.</p>
<table role="presentation" border="0" cellpadding="0" cellspacing="0"
class="btn btn-primary"

Loading…
Cancel
Save