Skip to content

Commit

Permalink
Merge branch 'master' into finish-multi-tenancy
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellarita authored Jan 29, 2017
2 parents 47bd046 + d40b3f7 commit 865b47a
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 16 deletions.
1 change: 1 addition & 0 deletions app/components/NavBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const NavBar = (props) =>{
<Link to="/createaccount" className="col-md-3">
Create Account
</Link>
<div className="col-md-5"> <a href='/api/auth/facebook/login' > Log in with Facebook </a> </div>
</div>
}
<div className="g-signin2" data-onsuccess="onSignIn"></div>
Expand Down
47 changes: 36 additions & 11 deletions app/components/proceedToCheckout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,19 @@ class Checkout extends Component {
const order = this.state.order;
order.email = emailToPass;


function getRandomIntInclusive(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
}


if(!this.state.currentuser){
order.orderNumber = crypto.randomBytes(5).toString('hex').toUpperCase();
this.setState({order: order})
axios.post('/api/sendmail', this.state.order)
this.setState({goToConfirmation: true})
this.props.purchase_func(this.state.order)

} else{
// console.log(this.state.order)
axios.post('/api/orders', this.state.order)
order.user_id = getRandomIntInclusive(1,1000000)
}

axios.post('/api/orders', this.state.order)
.then((res) => {
if(res === 'error'){this.setState({error: true})}
else{
Expand All @@ -66,9 +69,31 @@ class Checkout extends Component {
this.props.purchase_func(this.state.order)

}
})
})

}
// if(!this.state.currentuser){
// order.orderNumber = crypto.randomBytes(5).toString('hex').toUpperCase();
// order.user_id = getRandomIntInclusive(1,1000000)
// this.setState({order: order})
// axios.post('/api/sendmail', this.state.order)
// this.setState({goToConfirmation: true})
// this.props.purchase_func(this.state.order)

// } else{
// // console.log(this.state.order)
// axios.post('/api/orders', this.state.order)
// .then((res) => {
// if(res === 'error'){this.setState({error: true})}
// else{
// order.orderNumber = res.data.orderNumber;
// this.setState({order:order})
// this.setState({goToConfirmation: true})
// this.props.purchase_func(this.state.order)

// }
// })

// }
// router.push('/confirmation')
}

Expand Down
1 change: 1 addition & 0 deletions db/models/oauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const OAuth = db.define('oauths', {
})

OAuth.V2 = (accessToken, refreshToken, profile, done) =>
// console.log('hello i am here')
OAuth.findOrCreate({
where: {
provider: profile.provider,
Expand Down
6 changes: 3 additions & 3 deletions server/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ OAuth.setupStrategy({
config: {
clientID: env.FACEBOOK_CLIENT_ID,
clientSecret: env.FACEBOOK_CLIENT_SECRET,
callbackURL: `${app.baseUrl}/api/auth/login/facebook`,
callbackURL: `${app.baseUrl}/api/auth/facebook/login`,
},
passport
})
Expand Down Expand Up @@ -82,10 +82,10 @@ passport.serializeUser((user, done) => {

passport.deserializeUser(
(id, done) => {
debug('will deserialize user.id=%d', id)
// debug('will deserialize user.id=%d', id)
User.findById(id)
.then(user => {
debug('deserialize did ok user.id=%d', user.id)
// debug('deserialize did ok user.id=%d', user.id)
done(null, user)
})
.catch(err => {
Expand Down
4 changes: 2 additions & 2 deletions server/sendmail.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Router.post('/', function(req,res,next){

// console.log(req.body.products[0].artistName)

var tempString = '';
var productString = '';

for (let i=0; i<req.body.products.length; i++){

Expand All @@ -34,7 +34,7 @@ var tempString = '';
}
var introString = '<h1> Thank you for your purchase! </h1> <p> You have the following purchases: </p>'

var emailString = introString + tempString
var emailString = introString + productString

const mailOptions = {
from: '[email protected]',
Expand Down

0 comments on commit 865b47a

Please sign in to comment.