Skip to content

Commit

Permalink
Merge branch 'develop' into ft-login-signup-with-email-164489784
Browse files Browse the repository at this point in the history
  • Loading branch information
mwibutsa committed Apr 9, 2019
2 parents f7eae09 + c72ba96 commit 6a96540
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .coveralls.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
repo_token: EC2Rj8qko27GeraaipSpFO2eOHCHQNDfZ
repo_token: uaTjvZzIlc7gXmcqdiDOEEZZ1e0bpGHGW
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ node_js:
install:
- npm i
script:
- npm run migrate
- npm run test
after_success:
- npm run coverage
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Authors Haven - A Social platform for the creative at heart.
[![Build Status](https://travis-ci.com/andela/strikers-ah-backend.svg?branch=develop)](https://travis-ci.com/andela/strikers-ah-backend)
[![Reviewed by Hound](https://img.shields.io/badge/Reviewed%20by-Hound-%239069ad.svg)](https://houndci.com)

[![Coverage Status](https://coveralls.io/repos/github/andela/strikers-ah-backend/badge.svg)](https://coveralls.io/github/andela/strikers-ah-backend)
## Vision

Create a community of like minded authors to foster inspiration and innovation
Expand Down
6 changes: 5 additions & 1 deletion controllers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ class User {
static async loginWithEmail(req, res) {
const { email, password } = req.body;
try {
const user = await UserModel.findOne({ where: { [Op.or]: [{ email }, { username: email }] } });
const user = await UserModel.findOne({
where: {
[Op.or]: [{ email }, { username: email }]
}
});
// verify password
if (user && helper.comparePassword(password, user.password)) {
// return user and token
Expand Down
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import bodyParser from 'body-parser';
import passport from 'passport';
import swaggerUi from 'swagger-ui-express';
import YAML from 'yamljs';
// import routes from './routes/routes';
import routes from './routes/routes';
import user from './routes/user';
// import Strategy from './middlewares/auth';
import Strategy from './middlewares/auth';

const swaggerDocument = YAML.load('./swagger.yaml');

Expand All @@ -23,12 +23,12 @@ const port = process.env.PORT || 3000;

app.listen(port);
app.use(passport.initialize());
// const strategy = new Strategy();
const strategy = new Strategy();
app.use('/api/v1/login', user);
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));

app.use('/', (req, res) => {
res.send("Welcome");
res.send('Welcome');
});


Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"test": "NODE_ENV=test nyc --reporter=html --reporter=text mocha --require @babel/polyfill --require @babel/register ./test/*.js --exit",
"start": "babel-node ./index.js",
"dev": "nodemon --exec babel-node ./index.js ",
"coverage": "nyc --reporter=lcov --reporter=text-lcov | coveralls",
"migrate": "node_modules/.bin/sequelize db:migrate:undo:all && node_modules/.bin/sequelize db:migrate",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"lint": "eslint ./",
"lint-fix": "eslint ./ --fix",
"fix-code": "prettier-eslint --write './**/*.js' "
Expand Down Expand Up @@ -61,6 +62,7 @@
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.12.4",
"istanbul": "^0.4.5",
"mocha": "^6.0.2",
"mocha-lcov-reporter": "^1.3.0",
"nodemon": "^1.18.10",
Expand Down

0 comments on commit 6a96540

Please sign in to comment.