Skip to content
This repository was archived by the owner on Mar 4, 2022. It is now read-only.

Commit 4a2549b

Browse files
committed
Merge branch 'development' of github.com:PurdueHackers/PH-Website
2 parents fc62c3a + dce9410 commit 4a2549b

File tree

5 files changed

+182
-320
lines changed

5 files changed

+182
-320
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2018 Ashwin Gokhale
3+
Copyright (c) 2018 Purdue Hackers
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

backend/config/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ const config = {
2020
EMAIL_SERVICE: env.EMAIL_SERVICE || 'gmail',
2121
MAILGUN_DOMAIN: env.MAILGUN_DOMAIN || 'mydomain',
2222
MAILGUN_SECRET: env.MAILGUN_SECRET || 'mysecret',
23-
GC_BUCKET: env.GC_BUCKET || 'mybucket'
23+
GC_BUCKET: env.GC_BUCKET || 'mybucket',
24+
SENDGRID_KEY: env.SENDGRID_KEY || 'sendgridkey'
2425
};
2526

2627
export default config;

backend/utils/email.ts

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as nodemailer from 'nodemailer';
2-
import * as mailgunTransport from 'nodemailer-mailgun-transport';
2+
import { Request } from 'express';
33
import { join } from 'path';
44
import { readFileSync } from 'fs';
55
import * as jwt from 'jsonwebtoken';
@@ -8,30 +8,15 @@ import CONFIG from '../config';
88
import { IEventModel } from '../models/event';
99
import { IMemberModel } from '../models/member';
1010
import { formatDate } from './';
11-
import { Request } from 'express';
1211

13-
// const transport = nodemailer.createTransport({
14-
// service: CONFIG.EMAIL_SERVICE,
15-
// host: 'smtp.gmail.com',
16-
// port: 587,
17-
// auth: {
18-
// user: CONFIG.EMAIL,
19-
// pass: CONFIG.EMAIL_PASSWORD
20-
// },
21-
// tls: {
22-
// rejectUnauthorized: false
23-
// },
24-
// debug: true
25-
// });
26-
27-
const transport = nodemailer.createTransport(
28-
mailgunTransport({
29-
auth: {
30-
api_key: CONFIG.MAILGUN_SECRET,
31-
domain: CONFIG.MAILGUN_DOMAIN
32-
}
33-
})
34-
);
12+
const transport = nodemailer.createTransport({
13+
host: 'smtp.sendgrid.net',
14+
port: 465,
15+
auth: {
16+
user: 'apikey',
17+
pass: CONFIG.SENDGRID_KEY
18+
}
19+
});
3520

3621
const resetTemplate = compile(
3722
readFileSync(join(__dirname, '../emails', 'reset.hbs'), 'utf8')
@@ -68,7 +53,9 @@ export const sendResetEmail = async (member: IMemberModel, req: Request) => {
6853
});
6954
member.resetPasswordToken = token;
7055
await member.save();
71-
const resetUrl =`${req.protocol}://${req.get('host')}/reset?token=${token}`;
56+
const resetUrl = `${req.protocol}://${req.get(
57+
'host'
58+
)}/reset?token=${token}`;
7259
return await _sendResetEmail(member, resetUrl);
7360
};
7461

@@ -107,7 +94,9 @@ export const sendAccountCreatedEmail = async (
10794
});
10895
member.resetPasswordToken = token;
10996
await member.save();
110-
const resetUrl =`${req.protocol}://${req.get('host')}/reset?token=${token}`;
97+
const resetUrl = `${req.protocol}://${req.get(
98+
'host'
99+
)}/reset?token=${token}`;
111100
return await _sendAccountCreatedEmail(
112101
member,
113102
event.name,

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
},
1414
"dependencies": {
1515
"@google-cloud/storage": "^1.7.0",
16+
"@sendgrid/mail": "^6.3.1",
1617
"axios": "^0.18.0",
1718
"bcrypt": "^2.0.1",
1819
"cookie-parser": "~1.4.3",
@@ -24,13 +25,11 @@
2425
"handlebars": "^4.0.11",
2526
"helmet": "^3.13.0",
2627
"jsonwebtoken": "^8.2.1",
27-
"mailgun-js": "^0.20.0",
2828
"mongodb": "^3.1.3",
2929
"mongoose": "^5.2.8",
3030
"morgan": "~1.9.0",
3131
"multer": "^1.3.1",
3232
"nodemailer": "^4.6.7",
33-
"nodemailer-mailgun-transport": "^1.4.0",
3433
"nodemon": "^1.17.3",
3534
"passport": "^0.4.0",
3635
"passport-jwt": "^4.0.0",
@@ -63,6 +62,7 @@
6362
"@types/nodemailer-mailgun-transport": "^1.3.3",
6463
"@types/passport": "^0.4.6",
6564
"@types/passport-jwt": "^3.0.1",
65+
"@types/sendgrid": "^4.3.0",
6666
"@types/validator": "^9.4.1",
6767
"concurrently": "^3.5.1",
6868
"eslint": "^5.3.0",

0 commit comments

Comments
 (0)