Skip to content

Commit

Permalink
bug(Email): Fix all email related bugs
Browse files Browse the repository at this point in the history
Give appropratie text to the verification email subject
Add the appropraite styling to the recieved emails
Fix the swagger endpoint for verify email link

[Fixes #167721942]
  • Loading branch information
cvjude committed Aug 6, 2019
1 parent d5cb477 commit d94f299
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 94 deletions.
1 change: 1 addition & 0 deletions .sequelizerc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const path = require('path');
require('@babel/register');

module.exports = {
'config': path.resolve('server/db/config', 'config.js'),
Expand Down
17 changes: 11 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"start": "node build/index.js",
"dev": "export NODE_ENV=production && DEBUG=dev && nodemon --exec babel-node server/index.js",
"dev": "export DEBUG=dev && NODE_ENV=production && nodemon --exec babel-node server/index.js",
"debug": "export DEBUG=dev && nodemon --exec babel-node server/index.js --inspect",
"clean": "rm -rf build && mkdir build && npm run copy-docs",
"build": "npm run clean && npm run migrate && babel -d ./build ./server",
Expand Down Expand Up @@ -42,6 +42,7 @@
"dotenv": "^6.0.0",
"errorhandler": "^1.5.0",
"express": "^4.16.3",
"faker": "^4.1.0",
"jsonwebtoken": "^8.3.0",
"morgan": "^1.9.1",
"multer": "^1.4.2",
Expand Down Expand Up @@ -77,9 +78,9 @@
"mocha": "^6.2.0",
"mocha-lcov-reporter": "^1.3.0",
"nock": "^10.0.6",
"nodemon": "^1.19.1",
"nyc": "^14.1.1",
"sinon": "^7.3.2",
"nodemon": "^1.17.4"
"sinon": "^7.3.2"
},
"husky": {
"hooks": {
Expand All @@ -92,4 +93,4 @@
"git add"
]
}
}
}
2 changes: 1 addition & 1 deletion server/controllers/userController.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class UserController {

const mail = new Mail({
to: user.email,
subject: 'Password Reset',
subject: "Welcome to Authors' Haven",
messageHeader: `Hi, ${user.firstname}!`,
messageBody: 'We are exicted to get you started. First, you have to verify your account. Just click on the link below',
iButton: true
Expand Down
15 changes: 15 additions & 0 deletions server/db/migrations/20190802091121-update-articleBody-row.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

module.exports = {
up: (queryInterface, Sequelize) => queryInterface
.changeColumn('Articles', 'articleBody', {
type: Sequelize.TEXT,
allowNull: false
}),

down: (queryInterface, Sequelize) => queryInterface
.changeColumn('Articles', 'articleBody', {
type: Sequelize.TEXT,
allowNull: false
}),
};
2 changes: 1 addition & 1 deletion server/db/models/article.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = (sequelize, DataTypes) => {
slugOptions: { lower: true }
});
Article.associate = function (models) {
Article.belongsTo(models.User, { foreignKey: 'id', onDelete: 'CASCADE' });
Article.belongsTo(models.User, { foreignKey: 'authorId', onDelete: 'CASCADE' });
};
return Article;
};
45 changes: 45 additions & 0 deletions server/db/seeders/20190802082211-seed-article-table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import faker from 'faker';

const tags = ['js', 'andela', 'react', 'culture', 'sequelize', 'homely', 'travel', 'anime', 'happy'];

const articles = [{
title: 'the title',
articleBody: 'test article body',
description: 'test description',
tagList: 'happy',
image: 'test image',
slug: 'the-title',
authorId: 1,
createdAt: new Date(),
updatedAt: new Date()
}, {
title: 'the title',
articleBody: 'test article body',
description: 'test description',
tagList: 'marriage',
image: 'test image',
slug: 'the-title-0337485',
authorId: 26,
createdAt: new Date(),
updatedAt: new Date()
}];
for (let i = 0; i < 20; i += 1) {
const title = faker.random.words();
articles.push({
title,
articleBody: faker.lorem.text(),
description: faker.lorem.sentence(),
tagList: tags[Math.floor(Math.random() * tags.length)],
image: faker.random.image(),
slug: title.split(' ').join('-') || title,
authorId: faker.random.number({ min: 1, max: 20 }),
createdAt: new Date(),
updatedAt: new Date()
});
}

module.exports = {
up: queryInterface => queryInterface.bulkInsert('Articles', articles, {}),

down: queryInterface => queryInterface.bulkDelete('Articles', null, {})
};
22 changes: 14 additions & 8 deletions server/docs/ah-commando-doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/errorResponse"

/users/facebook:
get:
tags:
Expand Down Expand Up @@ -198,6 +199,7 @@ paths:
description: Logout successful
'401':
description: Invalid login details

/user:
get:
tags:
Expand All @@ -215,6 +217,7 @@ paths:
$ref: "#/components/schemas/profile"
'401':
description: Authorization error

/users/passwordReset:
post:
tags:
Expand Down Expand Up @@ -252,6 +255,7 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/errorResponse"

/users/resetPassword/{id}/{token}:
put:
tags:
Expand Down Expand Up @@ -298,7 +302,8 @@ paths:
$ref: "#/components/schemas/errorResponse"
'500':
description: Server error
/user/confirmEmail:

/users/confirmEmail:
get:
tags:
- Users
Expand Down Expand Up @@ -328,6 +333,7 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/errorResponse"

put:
tags:
- Profiles
Expand Down Expand Up @@ -410,7 +416,7 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/errorResponse"

get:
tags:
- Articles
Expand Down Expand Up @@ -570,7 +576,7 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/errorResponse"
$ref: "#/components/schemas/errorResponse"



Expand Down Expand Up @@ -706,9 +712,9 @@ components:
password:
type: object
properties:
status:
status:
type: integer
message:
message:
type: string
profile:
type: object
Expand All @@ -730,8 +736,8 @@ components:
followers:
type: object
followings:
type: object
article:
type: object
article:
type: object
properties:
slug:
Expand All @@ -758,7 +764,7 @@ components:
type: object
properties:
image:
type: string
type: string
errorResponse:
type: object
properties:
Expand Down
Loading

0 comments on commit d94f299

Please sign in to comment.