Skip to content

Commit

Permalink
Merge branch 'develop' into chore/156100324/nazgul-cfh-landing-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
topseySuave authored Apr 9, 2018
2 parents c42bd5a + 77ad92d commit 461f9f3
Show file tree
Hide file tree
Showing 23 changed files with 596 additions and 265 deletions.
20 changes: 19 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
MONGOHQ_URL=<THE MONGODB LOCALHOST URL>
SECRET=<YOUR JWT SECRET>
MONGOHQ_URL_TEST=<THE MONGODB LOCALHOST TEST URL>

SECRET=<YOUR JWT SECRET>

FB_CLIENT_ID=<FACEBOOK CLIENT ID>
FB_CLIENT_SECRET=<FACEBOOK CLIENT SECRET>
FB_CALLBACK_URL==<FACEBOOK CALLBACK URL>

TWITTER_CONSUMER_KEY=<TWITTER_CONSUMER_KEY ID>
TWITTER_CONSUMER_SECRET=<TWITTER_CONSUMER_SECRET>
TWITTER_CALLBACK_URL=<TWITTER CALLBACK URL>

GOOGLE_CLIENT_ID=<GOOGLE_CLIENT_ID>
GOOGLE_CLIENT_SECRET=<GOOGLE_CLIENT_SECRET>
GOOGLE_CALLBACK_URL=<GOOGLE_CALLBACK_URL>

GITHUB_CLIENT_ID=<GITHUB_CLIENT_ID>
GITHUB_CLIENT_SECRET=<GITHUB_CLIENT_SECRET>
GITHUB_CALLBACK_URL=<GITHUB_CALLBACK_URL
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
public/lib/
server.js
23 changes: 23 additions & 0 deletions app..js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export default {
name: 'nazgul-cfh',
scripts: {
},
env: {
MONGOHQ_URL: {
required: true
}
},
formation: {
web: {
quantity: 1
}
},
addons: [

],
buildpacks: [
{
url: 'heroku/nodejs'
}
]
};
21 changes: 16 additions & 5 deletions app/controllers/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Module dependencies.
*/
const mongoose = require('mongoose');

const jwt = require('jsonwebtoken');

const User = mongoose.model('User');
Expand All @@ -16,7 +17,18 @@ require('dotenv').config();
* @returns {void}
*/
exports.authCallback = (req, res) => {
res.redirect('/chooseavatars');
const payload = {
_id: req.user._id
};
const token = jwt.sign({
payload,
}, process.env.SECRET);
const userData = {
token,
name: req.user.name
};
res.cookie('userData', JSON.stringify(userData));
res.redirect('/#!/');
};

/**
Expand All @@ -29,7 +41,7 @@ exports.signin = (req, res) => {
if (!req.user) {
res.redirect('/#!/signin?error=invalid');
} else {
res.redirect('/#!/app');
res.redirect('/#!');
}
};

Expand Down Expand Up @@ -161,14 +173,13 @@ exports.signUp = (req, res) => {
}
const payload = {
_id: newUser._id,
email: newUser.email
};
const token = jwt.sign({
payload,
}, process.env.SECRET);
return res.status(201).json({
message: 'User Created Successfully',
token
token,
name: newUser.name
});
});
} else {
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/signin.jade
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extends auth

block auth
form.signin.form-horizontal(action="/users/session", method="post")
form.signin.form-horizontal(action="/api/auth/login", method="post")
p.error= message
.control-group
label.control-label(for='email') Email
Expand Down
10 changes: 6 additions & 4 deletions config/config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
var _ = require('underscore');
const _ = require('underscore');

// Load app configuration

module.exports = _.extend(
require(__dirname + '/../config/env/all.js'),
require(__dirname + '/../config/env/' + process.env.NODE_ENV + '.json') || {});
require(`${__dirname}/../config/env/all.js`),
/* eslint-disable */
require(`${__dirname}/../config/env/${process.env.NODE_ENV}.js`) || {}
);

8 changes: 4 additions & 4 deletions config/env/all.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
var path = require('path'),
rootPath = path.normalize(__dirname + '/../..');
rootPath = path.normalize(__dirname + '/../..');
var keys = rootPath + '/keys.txt';

module.exports = {
root: rootPath,
port: process.env.PORT || 3001,
db: process.env.MONGOHQ_URL
root: rootPath,
port: process.env.PORT || 3001,
db: process.env.MONGOHQ_URL
};
28 changes: 28 additions & 0 deletions config/env/development.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

export default {
port: 3001,
db: process.env.MONGOHQ_URL,
app: {
name: 'Cards for Humanity - Development'
},
facebook: {
clientID: 'APP_ID',
clientSecret: 'APP_SECRET',
callbackURL: 'http://localhost:3000/auth/facebook/callback'
},
twitter: {
clientID: 'CONSUMER_KEY',
clientSecret: 'CONSUMER_SECRET',
callbackURL: 'http://localhost:3000/auth/twitter/callback'
},
github: {
clientID: 'APP_ID',
clientSecret: 'APP_SECRET',
callbackURL: 'http://localhost:3000/auth/github/callback'
},
google: {
clientID: 'APP_ID',
clientSecret: 'APP_SECRET',
callbackURL: 'http://localhost:3000/auth/google/callback'
}
};
10 changes: 5 additions & 5 deletions config/env/development.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
"facebook": {
"clientID": "APP_ID",
"clientSecret": "APP_SECRET",
"callbackURL": "http://cardsforhumanity.com:3000/auth/facebook/callback"
"callbackURL": "https://localhost:3000/auth/facebook/callback"
},
"twitter": {
"clientID": "CONSUMER_KEY",
"clientSecret": "CONSUMER_SECRET",
"callbackURL": "http://cardsforhumanity.com:3000/auth/twitter/callback"
"callbackURL": "https://localhost:3000/auth/twitter/callback"
},
"github": {
"clientID": "APP_ID",
"clientSecret": "APP_SECRET",
"callbackURL": "http://cardsforhumanity.com:3000/auth/github/callback"
"callbackURL": "https://localhost:3000/auth/github/callback"
},
"google": {
"clientID": "APP_ID",
"clientSecret": "APP_SECRET",
"callbackURL": "http://cardsforhumanity.com:3000/auth/google/callback"
}
"callbackURL": "https://localhost:3000/auth/google/callback"
},
}
29 changes: 29 additions & 0 deletions config/env/production.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export default {
app: {
name: 'Cards for Humanity'
},

twitter: {
clientID: process.env.TWITTER_CONSUMER_KEY,
clientSecret: process.env.TWITTER_CONSUMER_SECRET,
callbackURL: process.env.TWITTER_CALLBACK_URL
},

facebook: {
clientID: process.env.FB_CLIENT_ID,
clientSecret: process.env.FB_CLIENT_SECRET,
callbackURL: process.env.FB_CALLBACK_URL
},

google: {
clientID: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
callbackURL: process.env.GOOGLE_CALLBACK_URL
},

github: {
clientID: process.env.GITHUB_CLIENT_ID,
clientSecret: process.env.GITHUB_CLIENT_SECRET,
callbackURL: process.env.GITHUB_CALLBACK_URL
},
};
29 changes: 29 additions & 0 deletions config/env/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require('dotenv').config();

export default {
port: 3001,
db: process.env.MONGOHQ_URL_TEST,
app: {
name: 'Cards for Humanity - Test'
},
facebook: {
clientID: 'APP_ID',
clientSecret: 'APP_SECRET',
callbackURL: 'http://localhost:3000/auth/facebook/callback'
},
twitter: {
clientID: 'CONSUMER_KEY',
clientSecret: 'CONSUMER_SECRET',
callbackURL: 'http://localhost:3000/auth/twitter/callback'
},
github: {
clientID: 'APP_ID',
clientSecret: 'APP_SECRET',
callbackURL: 'http://localhost:3000/auth/github/callback'
},
google: {
clientID: 'APP_ID',
clientSecret: 'APP_SECRET',
callbackURL: 'http://localhost:3000/auth/google/callback'
}
};
3 changes: 2 additions & 1 deletion config/env/test.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"port": 3001,
"db": "process.env.MONGOHQ_URL,
"app": {
"name": "Cards for Humanity - Test"
"name": "Cards for Humanity - Test on travis"
},
"facebook": {
"clientID": "APP_ID",
Expand Down
30 changes: 30 additions & 0 deletions config/env/travis.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export default {
port: 3001,
app: {
name: 'Cards for Humanity - Test on Travis'
},

twitter: {
clientID: process.env.TWITTER_CONSUMER_KEY,
clientSecret: process.env.TWITTER_CONSUMER_SECRET,
callbackURL: 'https://localhost:3000/auth/twitter/callback'
},

facebook: {
clientID: process.env.FB_CLIENT_ID,
clientSecret: process.env.FB_CLIENT_SECRET,
callbackURL: 'https://localhost:3000/auth/facebook/callback'
},

google: {
clientID: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
callbackURL: 'https://localhost:3000/auth/google/callback'
},

github: {
clientID: process.env.GITHUB_CLIENT_ID,
clientSecret: process.env.GITHUB_CLIENT_SECRET,
callbackURL: 'https://localhost:3000/auth/facebook/callback'
},
};
2 changes: 1 addition & 1 deletion config/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module.exports = function(app, passport, mongoose) {
app.use(flash());

//dynamic helpers
app.use(helpers(config.app.name));
app.use(helpers(config.default.app.name));

//use passport session
app.use(passport.initialize());
Expand Down
Loading

0 comments on commit 461f9f3

Please sign in to comment.