Skip to content

Commit 285f48d

Browse files
committed
ft(#431)non-trainee-invitation
1 parent 27f9fb6 commit 285f48d

File tree

3 files changed

+59
-2
lines changed

3 files changed

+59
-2
lines changed

src/database/db.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import mongoose from 'mongoose'
55
import logger from '../utils/logger.utils'
66

77
// add your own uri below
8-
const uri =
8+
const uri = process.env.MONGO_DEV_URI
99
process.env.NODE_ENV === 'production'
1010
? process.env.MONGO_PROD_DB
1111
: process.env.NODE_ENV === 'test'

src/resolvers/userResolver.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ import { EmailPattern } from '../utils/validation.utils'
3737
import { Context } from './../context'
3838
import { UserInputError } from 'apollo-server'
3939
import { encodeOtpToToken, generateOtp } from '../utils/2WayAuthentication'
40-
import jwt from 'jsonwebtoken'
40+
import jwt from 'jsonwebtoken'
41+
import nonTraineeTemplate from '../utils/templates/nonTraineeTemplate'
4142
const octokit = new Octokit({ auth: `${process.env.Org_Repo_Access}` })
4243

4344
const SECRET = (process.env.SECRET as string) || 'mysq_unique_secret'
@@ -330,6 +331,10 @@ const resolvers: any = {
330331
invitation.status = 'accepted'
331332
await invitation.save()
332333
}
334+
if(user.role !=='trainee'){
335+
const content = nonTraineeTemplate( user.email,password,org.name)
336+
sendEmail(user.email,'Login Details',content,process.env.FRONTEND_LINK, process.env.ADMIN_EMAIL, process.env.ADMIN_PASS)
337+
}
333338

334339
const newProfile = await Profile.create({
335340
user,
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
const link = process.env.FRONTEND_LINK + '/login/org'
2+
3+
export default function Template(email:string,password:string,orgName:string) {
4+
return /* html */ `
5+
<table style="font-size: 16px; font-family: 'Rubik'; text-align: left">
6+
<tbody>
7+
<tr>
8+
<td>
9+
<br />
10+
<p style="margin-bottom: 5px">
11+
Welcome to <strong>${orgName}</strong> organization, Below are your login details:<br>
12+
You have signed up with email: <strong>${email}</strong>, and password: <strong>${password}</strong>. <br>
13+
You will now use it to login from here on.
14+
</p>
15+
<p style="margin-bottom: 10px">
16+
Use the button below to login into the organization.
17+
</p>
18+
19+
20+
<a href="${link}" style="text-decoration: none; cursor: pointer">
21+
<button
22+
style="
23+
font-size: 16px;
24+
background-color: rgb(134, 103, 242);
25+
font-family: 'Rubik';
26+
text-align: center;
27+
border: none;
28+
border-radius: 3px;
29+
padding: 5px;
30+
cursor: pointer;
31+
color: whitesmoke;
32+
"
33+
>
34+
Login
35+
</button>
36+
</a>
37+
<br />
38+
<br />
39+
40+
<p>
41+
If you think this email reached your inbox by mistake, simply ignore it.
42+
</p>
43+
<br />
44+
<br />
45+
46+
<p>Best Regard,</p>
47+
<p>Pulse team</p>
48+
</td>
49+
</tr>
50+
</tbody>
51+
</table>`
52+
}

0 commit comments

Comments
 (0)