Skip to content
This repository has been archived by the owner on Feb 15, 2021. It is now read-only.

Final touches #6

Open
wants to merge 50 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
d9a382d
change titles to bookswap
Aug 1, 2017
6cf4f53
Merge pull request #1 from jklugherz/jklugherz
Aug 1, 2017
ab1c474
update readme
Aug 1, 2017
b11ada6
Merge pull request #2 from jklugherz/jklugherz
Aug 1, 2017
4f2bbee
add nodemon, edit README, finesse home page
Aug 2, 2017
68267f1
Merge pull request #3 from jklugherz/jklugherz
Aug 2, 2017
12cc24d
user profile
Aug 2, 2017
8191df4
Merge branch 'master' into night
Aug 2, 2017
f9c2379
Merge pull request #4 from jklugherz/night
Aug 2, 2017
89b3122
remove books
Aug 2, 2017
9bd8f80
Merge pull request #5 from jklugherz/remove
Aug 2, 2017
c9af4ed
search books route/view
Aug 2, 2017
659c48f
Merge branch 'master' of https://github.com/jklugherz/bookswap into j…
Aug 2, 2017
78cb002
Merge pull request #6 from jklugherz/jklugherz
Aug 2, 2017
44c49c5
departmnet
Aug 2, 2017
83456a4
ok
Aug 2, 2017
2074a33
Merge pull request #7 from jklugherz/lunch
Aug 2, 2017
2b2c2b3
fixing add book and profile
Aug 2, 2017
8611562
Merge pull request #8 from jklugherz/tinkering
Aug 2, 2017
125e71c
emails
Aug 2, 2017
3a75480
fixing search on home
Aug 2, 2017
b81a988
fix search bar conflict
Aug 2, 2017
860f237
Merge pull request #9 from jklugherz/jklugherz
Aug 2, 2017
bc493f0
last 3
Aug 2, 2017
d4c93fa
Merge pull request #10 from jklugherz/top-ten
Aug 2, 2017
181f8cf
regex for search
Aug 2, 2017
54ea0f9
Merge branch 'master' of https://github.com/jklugherz/bookswap into j…
Aug 2, 2017
1353267
Merge pull request #11 from jklugherz/jklugherz
Aug 2, 2017
f929aa3
search first word
Aug 3, 2017
0721c89
Merge pull request #12 from jklugherz/last
Aug 3, 2017
aac32cf
updated search |
Aug 3, 2017
485fb0c
Merge pull request #13 from jklugherz/google
Aug 3, 2017
6aaea5b
hashed passwords
Aug 3, 2017
9e67abd
Merge pull request #14 from jklugherz/hash
Aug 3, 2017
99d700d
searchresults
Aug 4, 2017
70271bf
Merge pull request #15 from jklugherz/jklugherz
Aug 4, 2017
bd2a984
email seller
Aug 4, 2017
fbcbd66
send email
Aug 4, 2017
3a0e8c6
Merge branch 'master' of https://github.com/jklugherz/bookswap into e…
Aug 4, 2017
eb8f7a2
contact seller form complete
Aug 4, 2017
cc03063
Merge pull request #16 from jklugherz/email
Aug 4, 2017
9f5f64c
start
Aug 5, 2017
f4ee364
email is working
Aug 7, 2017
c666592
Merge pull request #17 from jklugherz/email2
Aug 7, 2017
939e309
fonts and email sent
Aug 7, 2017
5df7645
Merge pull request #18 from jklugherz/style
Aug 7, 2017
d05a9c8
scroll and departments
Aug 8, 2017
9ff47ce
Merge pull request #19 from jklugherz/tues
Aug 8, 2017
b18c3dc
scroll height
Aug 8, 2017
dca7265
fixed button and cents
Aug 11, 2017
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
24 changes: 4 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
# Horizons Hackathon Template.
# BookSwap
Julia Klugherz and Reed Feldman

## Steps 1: Get your project set-up
You have two ways of working on your project: Local and Gomix.
## Overview

### Local development
1. Clone the repo.
1. Create a `env.sh` file that contains:

```
export MONGODB_URI='YOUR URI';
export SECRET='YOUR SECRET'
```

1. Run `source .env`, and you are good to go!

### Glitch Development

1. Go to https://glitch.com/edit/#!/horizons-hackathon and click
`Remix this 🎤`
1. Select `.env` on the left panel, add your `MONGODB_URI` and `SECRET`
1. Click `Show` at the top to preview your app!
This is a simple template for a college textbook-exchange app.
19 changes: 12 additions & 7 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ var passport = require('passport');
var LocalStrategy = require('passport-local');
var mongoose = require('mongoose');
var connect = process.env.MONGODB_URI;
var _ = require('underscore');
var bcrypt = require('bcrypt');


//what is secret MONGODB_URI???
var REQUIRED_ENV = "SECRET MONGODB_URI".split(" ");

REQUIRED_ENV.forEach(function(el) {
Expand All @@ -23,7 +27,6 @@ REQUIRED_ENV.forEach(function(el) {
mongoose.connect(connect);

var models = require('./models');

var routes = require('./routes/routes');
var auth = require('./routes/auth');
var app = express();
Expand Down Expand Up @@ -75,14 +78,17 @@ passport.use(new LocalStrategy(function(username, password, done) {
return done(null, false, { message: 'Incorrect username.' });
}
// if passwords do not match, auth failed
if (user.password !== password) {
return done(null, false, { message: 'Incorrect password.' });
}
bcrypt.compare(password, user.password, function(err, res) {
// res == true
if (!res) {
done(null, false, { message: 'Incorrect password.' });
return;
}
// auth has has succeeded
return done(null, user);
});
}
));
})
}));

app.use('/', auth(passport));
app.use('/', routes);
Expand Down Expand Up @@ -121,5 +127,4 @@ app.use(function(err, req, res, next) {
var port = process.env.PORT || 3000;
app.listen(port);
console.log('Express started. Listening on port %s', port);

module.exports = app;
49 changes: 49 additions & 0 deletions departments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
var depts = [
'African American Studies',
'American Cultural Studies',
'Anthropology',
'Art & Visual Culture',
'Asian Studies',
'Biological Chemistry',
'Biology',
'Chemistry',
'Chinese',
'Classical & Medieval Studies',
'Dance',
'Digital & Computational Studies',
'East Asian Studies',
'Economics',
'Educational Studies',
'English',
'Environmental Studies',
'European Studies',
'French & Francophone Studies',
'Geology',
'German',
'Greek',
'History',
'Interdisciplinary Studies',
'Japanese',
'Latin',
'Latin American Studies',
'Mathematics',
'Music',
'Neuroscience',
'Philosophy',
'Phyiscal Education',
'Physics',
'Politics',
'Psychology',
'Religious Studies',
'Rhetoric',
'Russian',
'Sociology',
'Spanish',
'Teacher Education',
'Theater',
"Women & Gender Studies"
];

module.exports = {
depts
}
20 changes: 16 additions & 4 deletions models.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,25 @@ var mongoose = require('mongoose');
var userSchema = mongoose.Schema({
username: String,
password: String,
email: String,
phone: String
});



User = mongoose.model('User', userSchema);
//after we add a book, I need to add that book to the user scheme via helper function.
const bookSchema = mongoose.Schema({
email: String,
owner: {
ref: User,
type: mongoose.Schema.Types.ObjectId
},
title: String,
author: String,
department: String,
price: String,
});
const Book = mongoose.model('Book', bookSchema);

module.exports = {
User:User
User: User,
Book: Book
};
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "doublemessage",
"name": "bookswap",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node app.js"
},
"dependencies": {
"bcrypt": "^1.0.2",
"body-parser": "~1.13.2",
"connect-mongo": "^1.3.2",
"cookie-parser": "~1.3.5",
Expand All @@ -14,10 +15,13 @@
"express-handlebars": "^3.0.0",
"express-session": "^1.13.0",
"hbs": "~3.1.0",
"mailgun": "^0.5.0",
"mailgun-js": "^0.12.0",
"mongoose": "^4.5.1",
"mongoose-findorcreate": "^0.1.2",
"morgan": "~1.6.1",
"multer": "^1.1.0",
"nodemon": "^1.11.0",
"passport": "^0.3.2",
"passport-facebook": "^2.1.1",
"passport-local": "^1.0.0",
Expand Down
30 changes: 30 additions & 0 deletions public/stylesheets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,33 @@ body {
padding-top: 6.5rem;
font: 14px "Open Sans", Helvetica, Arial, sans-serif;
}

.bates {
background-color: #3a3a3a !important;
}

.batestext {
color: #fff !important
}

.button {
margin-bottom: 2em !important
}

.font {
font-family: courier !important
}

.search {
color: #fff !important;
background-color: #337ab7 !important;

}

.profile {
text-decoration: underline !important;
}

.container-outer { overflow: scroll; width: 100%; height: 300px; }

.container-inner { width: 5000; }
42 changes: 29 additions & 13 deletions routes/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
var express = require('express');
var router = express.Router();
var models = require('../models');
var _ = require('underscore');
var bcrypt = require('bcrypt');


module.exports = function(passport) {

Expand All @@ -17,20 +20,33 @@ module.exports = function(passport) {
error: "Passwords don't match."
});
}
var u = new models.User({
username: req.body.username,
password: req.body.password
if (req.body.email.substr(req.body.email.length-3) !== 'edu') {
return res.render('signup', {
error: "Please enter a valid .edu email address."
})
}
//hash
var params = _.pick(req.body, ['username', 'password', 'email']);
bcrypt.genSalt(10, function(err, salt) {
bcrypt.hash(params.password, salt, function(err, hash) {
// Store hash in your password DB.
params.password = hash;
Object.assign(params);
models.User.create(params, function(err, user) {
if (err) {
res.status(400).json({
success: false,
error: err.message
});
} else {
console.log(user);
res.redirect('/login')
}
});
});
u.save(function(err, user) {
if (err) {
console.log(err);
res.status(500).redirect('/register');
return;
}
console.log(user);
res.redirect('/login');
});
});
});


// GET Login page
router.get('/login', function(req, res) {
Expand All @@ -39,7 +55,7 @@ module.exports = function(passport) {

// POST Login page
router.post('/login', passport.authenticate('local',{
successRedirect: '/protected',
successRedirect: '/profile',
failureRedirect: '/login'
}));

Expand Down
Loading