Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/resolvers/userResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ import { EmailPattern } from '../utils/validation.utils'
import { Context } from './../context'
import { UserInputError } from 'apollo-server'
import { encodeOtpToToken, generateOtp } from '../utils/2WayAuthentication'
import jwt from 'jsonwebtoken'
import jwt from 'jsonwebtoken'
import nonTraineeTemplate from '../utils/templates/nonTraineeTemplate'
const octokit = new Octokit({ auth: `${process.env.Org_Repo_Access}` })

const SECRET = (process.env.SECRET as string) || 'mysq_unique_secret'
Expand Down Expand Up @@ -328,6 +329,10 @@ const resolvers: any = {
invitation.status = 'accepted'
await invitation.save()
}
if(user.role !=='trainee'){
const content = nonTraineeTemplate( user.email,password,org.name)
sendEmail(user.email,'Login Details',content,process.env.FRONTEND_LINK, process.env.ADMIN_EMAIL, process.env.ADMIN_PASS)
}

const newProfile = await Profile.create({
user,
Expand Down
52 changes: 52 additions & 0 deletions src/utils/templates/nonTraineeTemplate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const link = process.env.FRONTEND_LINK + '/login/org'

export default function Template(email:string,password:string,orgName:string) {
return /* html */ `
<table style="font-size: 16px; font-family: 'Rubik'; text-align: left">
<tbody>
<tr>
<td>
<br />
<p style="margin-bottom: 5px">
Welcome to <strong>${orgName}</strong> organization, Below are your login details:<br>
You have signed up with email: <strong>${email}</strong>, and password: <strong>${password}</strong>. <br>
You will now use it to login from here on.
</p>
<p style="margin-bottom: 10px">
Use the button below to login into the organization.
</p>


<a href="${link}" style="text-decoration: none; cursor: pointer">
<button
style="
font-size: 16px;
background-color: rgb(134, 103, 242);
font-family: 'Rubik';
text-align: center;
border: none;
border-radius: 3px;
padding: 5px;
cursor: pointer;
color: whitesmoke;
"
>
Login
</button>
</a>
<br />
<br />

<p>
If you think this email reached your inbox by mistake, simply ignore it.
</p>
<br />
<br />

<p>Best Regard,</p>
<p>Pulse team</p>
</td>
</tr>
</tbody>
</table>`
}
Loading