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 4 years ago
parent
commit
15933af443
  1. 19
      packages/nc-gui/components/auth/userManagement.vue
  2. 8
      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) { async rensendInvite(id) {
try { try {
await this.$axios.post('/admin/resendInvite/' + id, null, { await this.$axios.post('/admin/resendInvite/' + id, {
projectName: this.$store.getters['project/GtrProjectName'],
}, {
headers: { headers: {
'xc-auth': this.$store.state.users.token 'xc-auth': this.$store.state.users.token
},
params: {
project_id: this.$route.params.project_id
} }
}); });
this.$toast.success('Invite email sent successfully').goAway(3000); this.$toast.success('Invite email sent successfully').goAway(3000);
@ -620,7 +625,11 @@ export default {
}, },
async inviteUser(email) { async inviteUser(email) {
try { 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: { headers: {
'xc-auth': this.$store.state.users.token 'xc-auth': this.$store.state.users.token
} }
@ -646,7 +655,8 @@ export default {
await this.$axios.put('/admin/' + this.selectedUser.id, { await this.$axios.put('/admin/' + this.selectedUser.id, {
roles: this.selectedUser.roles, roles: this.selectedUser.roles,
email: this.selectedUser.email, 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: { headers: {
'xc-auth': this.$store.state.users.token 'xc-auth': this.$store.state.users.token
@ -655,7 +665,8 @@ export default {
} else { } else {
data = await this.$axios.post('/admin', { data = await this.$axios.post('/admin', {
...this.selectedUser, ...this.selectedUser,
project_id: this.$route.params.project_id project_id: this.$route.params.project_id,
projectName: this.$store.getters['project/GtrProjectName']
}, { }, {
headers: { headers: {
'xc-auth': this.$store.state.users.token 'xc-auth': this.$store.state.users.token

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

@ -546,7 +546,8 @@ export default class RestAuthCtrl {
lastname: user.lastname, lastname: user.lastname,
id: user.id, id: user.id,
roles: user.roles roles: user.roles
}, this.config.auth.jwt.secret, this.config.auth.jwt.options) }, this.config.auth.jwt.secret,
this.config.auth.jwt.options)
} as any); } as any);
} catch (e) { } catch (e) {
console.log(e); console.log(e);
@ -1168,6 +1169,7 @@ export default class RestAuthCtrl {
return next(new Error(`User with id '${req.params.id}' not found`)); return next(new Error(`User with id '${req.params.id}' not found`));
} }
req.body.roles = user.roles;
const invite_token = uuidv4(); const invite_token = uuidv4();
await this.users.update({ await this.users.update({
@ -1197,13 +1199,13 @@ export default class RestAuthCtrl {
const template = (await import('./ui/emailTemplates/invite')).default; const template = (await import('./ui/emailTemplates/invite')).default;
if (this.emailClient) { if (this.emailClient) {
await this.emailClient.mailSend({ await this.emailClient.mailSend({
to: email, to: email,
subject: "Verify email", subject: "Verify email",
html: ejs.render(template, { html: ejs.render(template, {
signupLink: `${req.ncSiteUrl}${this.config?.dashboardPath}#/user/authentication/signup/${token}`, 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 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;"> <p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; margin-bottom: 15px;">
Hi,</p> Hi,</p>
<p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; margin-bottom: 15px;"> <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> Click the button below to to accept my invitation.</p>
<table role="presentation" border="0" cellpadding="0" cellspacing="0" <table role="presentation" border="0" cellpadding="0" cellspacing="0"
class="btn btn-primary" class="btn btn-primary"

Loading…
Cancel
Save