This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.authenticate_user = (req, res, next) => { | |
const { username, password } = req.body; | |
const API_URL = require('../../utils/constants/api_urls/api_urls'); | |
const { fetchToken } = API_URL; | |
//DEVELOPMENT VALUES FOR TESTING ONLY | |
const body = { | |
client_id: 'cp', | |
client_secret: 'secret', | |
grant_type: 'password', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const router = express.Router(); | |
const customer_controller = require('../controllers/customers'); | |
//Returns all customers belonging to a user | |
router.get('/:userid', customer_controller.customer_get); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mongoose = require('mongoose'); | |
const User = require('../models/user'); | |
const Customer = require('../models/Customer'); | |
//Create customer | |
exports.customer_add = (req, res) => { | |
const { body, params } = req; | |
const { name, email, phone, contact, street, | |
city, state, zipcode, dotInterval } = body; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const User = require('../models/user'); | |
exports.user_login = (req, res) => { | |
const { body } = req; | |
const { username, password } = body; | |
User.find({ username: username }, (err, user) => { | |
if (err) | |
res.send({ | |
status: 404, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mongoose = require('mongoose'); | |
const User = require('./user'); | |
const CustomerSchema = new mongoose.Schema({ | |
user: { | |
type: mongoose.Schema.Types.ObjectId, | |
ref: 'User', | |
}, | |
name: { | |
type: String, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mongoose = require('mongoose'); | |
// *** NOTE: You never want to store a plain password in production! If someone gains access to your database, they will have access to all the users passwords. | |
// You can use something like PassportJS to handle saving passwords | |
const UserSchema = new mongoose.Schema({ | |
username: { | |
type: String, | |
default: '', | |
}, | |
password: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MLAB_URL="mongodb://<db_username>:<db_password>@ds147520.mlab.com:25653/database_name" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const router = express.Router(); | |
const app = express(); | |
const port = process.env.PORT || 3000; | |
//Allows use of enviroment variables | |
require('dotenv').config({ path: __dirname + '/.env' }); | |
//API Routes | |
const users = require('./routes/users'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from "react"; | |
import styled from "styled-components"; | |
import PropTypes from "prop-types"; | |
import { connect } from "react-redux"; | |
import { didScorecardSubmit } from "../../actions/roundActions"; | |
//Components | |
import EnterBtn from "./EnterBtn"; | |
const ScorecardWrapper = styled.div` |