├── server
├── controller
│ ├── profController.js
│ ├── searchController.js
│ └── userController.js
├── server.js
├── routes.js
└── handlers.js
├── .gitignore
├── app
├── collections
│ ├── dogs.js
│ ├── users.js
│ └── walkers.js
├── models
│ ├── dog.js
│ ├── walker.js
│ └── user.js
└── config.js
├── index.js
├── client
├── auth
│ ├── signin.html
│ ├── signup.html
│ └── auth.js
├── dashboard
│ ├── search.js
│ └── search.html
├── profile
│ ├── profile.js
│ └── profile.html
├── landing
│ ├── landing.html
│ └── landing.js
├── index.html
├── app.js
└── services
│ └── services.js
├── package.json
├── README.md
└── CONTRIBUTING.md
/server/controller/profController.js:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/server/controller/searchController.js:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /node_modules
2 | client/lib
3 | /db
4 | /env
5 |
--------------------------------------------------------------------------------
/app/collections/dogs.js:
--------------------------------------------------------------------------------
1 | var db = require('../config');
2 | var Dog = require('../models/dog');
3 |
4 | var Dogs = new db.Collection();
5 |
6 | Dogs.model = Dog;
7 |
8 | module.exports = Dogs;
9 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | var app = require('./server/server.js');
2 |
3 | var port = process.env.PORT || 8000;
4 |
5 | app.listen(port, function() {
6 | console.log("Server listening on port " + port);
7 | });
8 |
--------------------------------------------------------------------------------
/app/collections/users.js:
--------------------------------------------------------------------------------
1 | var db = require('../config');
2 | var User = require('../models/dog');
3 |
4 | var Users = new db.Collection();
5 |
6 | Users.model = User;
7 |
8 | module.exports = Users;
9 |
--------------------------------------------------------------------------------
/app/collections/walkers.js:
--------------------------------------------------------------------------------
1 | var db = require('../config');
2 | var Walker = require('../models/dog');
3 |
4 | var Walkers = new db.Collection();
5 |
6 | Walkers.model = Walker;
7 |
8 | module.exports = Walkers;
9 |
--------------------------------------------------------------------------------
/app/models/dog.js:
--------------------------------------------------------------------------------
1 | var db = require('../config');
2 | var Promise = require('bluebird');
3 |
4 | var Dog = db.Model.extend({
5 | tableName: 'dogs',
6 | hasTimestamps: true,
7 | initialize: function() {
8 |
9 | },
10 | });
11 |
12 | module.exports = Dog;
13 |
--------------------------------------------------------------------------------
/app/models/walker.js:
--------------------------------------------------------------------------------
1 | var db = require('../config');
2 | var Promise = require('bluebird');
3 |
4 | var Walker = db.Model.extend({
5 | tableName: 'walkers',
6 | hasTimestamps: true,
7 | initialize: function() {
8 |
9 | },
10 | });
11 |
12 | module.exports = Walker;
13 |
--------------------------------------------------------------------------------
/client/auth/signin.html:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/client/dashboard/search.js:
--------------------------------------------------------------------------------
1 | angular.module('doggyBook.search', [])
2 |
3 | .controller('SearchController', function($scope, Players) {
4 | $scope.data = {};
5 | $scope.getUsers = function () {
6 | Search.getAllUsers()
7 | .then(function(users) {
8 | $scope.data.users = users;
9 | })
10 | .catch(function(error) {
11 | console.error(error);
12 | });
13 | }
14 | });
15 |
--------------------------------------------------------------------------------
/client/dashboard/search.html:
--------------------------------------------------------------------------------
1 |
2 |
Enter price here!
3 |
8 |
9 |
10 |
11 | -
12 | {{data.users}}
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/client/auth/signup.html:
--------------------------------------------------------------------------------
1 |
15 |
--------------------------------------------------------------------------------
/client/profile/profile.js:
--------------------------------------------------------------------------------
1 | angular.module('doggyBook.profile', [])
2 |
3 | .controller('ProfController', function ($scope, Profiles) {
4 | // Profiles is a factory in services.js
5 | $scope.userID = $scope.userID;
6 | // grab userID from either landing page or search page
7 | $scope.data = {};
8 |
9 | var profileRender = function () {
10 | Profiles.showProfile($scope.userID)
11 | // showProfile is a function in the Profiles factory that queries the database for a given userID
12 | .then(function (profData) {
13 | $scope.data = profData;
14 | })
15 | .catch(function (error) {
16 | console.error(error);
17 | });
18 | };
19 |
20 | profileRender();
21 | });
22 |
--------------------------------------------------------------------------------
/client/landing/landing.html:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/client/landing/landing.js:
--------------------------------------------------------------------------------
1 | // currently no functionality - the page only has links to sign-in and signup
2 | // we might want to run a check here that checks if a user is signed in;
3 | // if so, display a signout link instead of a signin link, also display links to profile & search
4 |
5 | angular.module('doggyBook.landing', [])
6 |
7 | .controller('LandingController', function($scope, Players) {
8 | //only starting the file -> should be able to route to other files; nothing else for now;
9 | $scope.data = {};
10 | $scope.landingFunction = function () {
11 | landing.landingFunc()
12 | .then(function() {
13 | $scope.data.landingData = landingData;
14 | })
15 | .catch(function(error) {
16 | console.error(error);
17 | });
18 | }
19 | });
20 |
--------------------------------------------------------------------------------
/server/server.js:
--------------------------------------------------------------------------------
1 | console.log('in server.js');
2 | // this should actually be server-config.js
3 | // the server executes from the require call in index.js from the root directory
4 |
5 | var db = require('../app/config');
6 |
7 | var express = require('express');
8 | var bodyParser = require('body-parser');
9 |
10 | var app = express();
11 |
12 | // middleware
13 | app.use(express.static('client'));
14 | app.use(bodyParser.json());
15 |
16 |
17 | var routes = require('./routes')(app, express);
18 | // var handle = require('./handlers.js');
19 |
20 |
21 |
22 | // app.post('/api/users/signup', handle.signup);
23 | // app.post('/api/users/signin', handle.signin);
24 | // app.get('/api/dogs', handle.dogSearch);
25 | // app.get('/api/walkers', handle.walkerSearch);
26 |
27 |
28 | module.exports = app;
29 |
--------------------------------------------------------------------------------
/client/auth/auth.js:
--------------------------------------------------------------------------------
1 | angular.module('doggyBook.auth', [])
2 |
3 | .controller('AuthController', function ($scope, $window, $location, Auth) {
4 | $scope.user = {};
5 |
6 | $scope.signin = function () {
7 | Auth.signin($scope.user)
8 | .then(function (token) {
9 | $window.localStorage.setItem('com.doggyBook', token);
10 | $location.path('/dashboard');
11 | })
12 | .catch(function (error) {
13 | console.error(error);
14 | });
15 | };
16 |
17 | $scope.signup = function () {
18 | Auth.signup($scope.user)
19 | .then(function (token) {
20 | $window.localStorage.setItem('com.doggyBook', token);
21 | $location.path('/dashboard');
22 | })
23 | .catch(function (error) {
24 | console.error(error);
25 | });
26 | };
27 | });
28 |
--------------------------------------------------------------------------------
/client/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Doggybook
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/client/profile/profile.html:
--------------------------------------------------------------------------------
1 |
2 |
Profile
3 |
4 |
14 |
15 |
16 |
17 |
18 |
19 |
{{profile.name}}
20 |

21 |
22 |
23 | - {{profile.userType}}
24 | - {{profile.location}}
25 |
26 | - {{profile.walkType}}
27 |
28 | - {{profile.walkTime}}
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "doggybook",
3 | "version": "1.0.0",
4 | "description": "\"Connecting dogs with walkers, book your dog walker!\"",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "repository": {
10 | "type": "git",
11 | "url": "git+https://github.com/req-raccoons/doggybook.git"
12 | },
13 | "keywords": [
14 | "dogs",
15 | "dog",
16 | "walker",
17 | "dog-walking"
18 | ],
19 | "author": "req.raccoons",
20 | "license": "ISC",
21 | "bugs": {
22 | "url": "https://github.com/req-raccoons/doggybook/issues"
23 | },
24 | "homepage": "https://github.com/req-raccoons/doggybook#readme",
25 | "dependencies": {
26 | "bcrypt-nodejs": "0.0.3",
27 | "bluebird": "^3.4.7",
28 | "body-parser": "^1.16.0",
29 | "bookshelf": "^0.10.2",
30 | "express": "^4.14.0",
31 | "jwt-simple": "^0.5.1",
32 | "knex": "^0.12.6",
33 | "mysql": "^2.12.0",
34 | "path": "^0.12.7",
35 | "q": "^1.4.1",
36 | "request": "^2.79.0",
37 | "sqlite3": "^3.1.8"
38 | },
39 | "devDependencies": {
40 | "sqlite3": "^3.1.8"
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/server/routes.js:
--------------------------------------------------------------------------------
1 |
2 | var profController = require('./controller/profController.js');
3 | var searchController = require('./controller/searchController.js');
4 | // var userController = require('./controller/userController.js');
5 |
6 | // we can rename this later, but this is the 'controller' for users
7 | // userController has been commented out to accomodate this
8 | var handle = require('./handlers');
9 |
10 |
11 | module.exports = function (app, express) {
12 | console.log('loading routes...');
13 | app.post('/api/signin', handle.signin);
14 | app.post('/api/signup', handle.signup);
15 | // not yet implemented in handlers
16 | // app.get('/api/signedin', handle.checkAuth);
17 |
18 |
19 | /* these controllers have not been defined yet, so it is breaking the server.
20 | * uncomment when/as they are defined
21 |
22 | // authentication middleware used to decode token and made available on the request
23 | // app.use('/api/links', helpers.decode);
24 | app.get('/api/prof/', profController.displayProf);
25 | app.post('/api/prof/', profController.editProf);
26 |
27 | //vvv someone sends a search request
28 | app.post('/api/search/', searchController.newSearchQuery);
29 | //vvv might not be necessary? sends the results of the search request
30 | app.get('/api/search/', searchController.displaySearchQuery);
31 |
32 | */
33 |
34 | };
35 |
--------------------------------------------------------------------------------
/app/models/user.js:
--------------------------------------------------------------------------------
1 | var db = require('../config');
2 | var bcrypt = require('bcrypt-nodejs');
3 | var Promise = require('bluebird');
4 |
5 | var User = db.Model.extend({
6 | tableName: 'users',
7 | hasTimestamps: true,
8 | initialize: function() {
9 | this.on('creating', this.hashPassword);
10 | },
11 | comparePassword: function(attemptedPassword, callback) {
12 | var hashcheck = Promise.promisify(bcrypt.compare);
13 |
14 | hashcheck(attemptedPassword, this.get('password'))
15 | .then(function(isMatch) {
16 | callback(isMatch);
17 | });
18 | // bcrypt.compare(attemptedPassword, this.get('password'), function(err, isMatch) {
19 | // });
20 | },
21 | hashPassword: function() {
22 | console.log(`'this' is: `, this);
23 | var cipher = Promise.promisify(bcrypt.hash);
24 |
25 | return cipher(this.get('password'), null, null).bind(this)
26 | .then(function(hash) {
27 | this.set('password', hash);
28 | });
29 | },
30 | });
31 |
32 | module.exports = User;
33 |
34 |
35 |
36 | // var hash = bcrypt.hashSync("bacon");
37 | //
38 | // bcrypt.compareSync("bacon", hash); // true
39 | // bcrypt.compareSync("veggies", hash); // false
40 | // Asynchronous
41 | //
42 | // bcrypt.hash("bacon", null, null, function(err, hash) {
43 | // // Store hash in your password DB.
44 | // });
45 | //
46 | // // Load hash from your password DB.
47 | // bcrypt.compare("bacon", hash, function(err, res) {
48 | // // res == true
49 | // });
50 | // bcrypt.compare("veggies", hash, function(err, res) {
51 | // // res = false
52 | // });
53 |
--------------------------------------------------------------------------------
/app/config.js:
--------------------------------------------------------------------------------
1 | console.log('loading db...');
2 | var dbconfig = require('../env/db');
3 | // console.log(dbconfig);
4 |
5 | var path = require('path');
6 | var knex = require('knex')(dbconfig);
7 | var db = require('bookshelf')(knex);
8 |
9 | db.knex.schema.hasTable('users')
10 | .then(function(exists) {
11 | if (!exists) {
12 | db.knex.schema.createTable('users', function(user) {
13 | user.increments('id').primary();
14 | user.string('username', 100).unique();
15 | user.string('email', 100).unique();
16 | user.string('password', 100);
17 | user.boolean('isDog');
18 | user.timestamps();
19 | }).then(function(table) {
20 | console.log('Created Table: ', table);
21 | });
22 | }
23 | });
24 |
25 | db.knex.schema.hasTable('dogs')
26 | .then(function(exists) {
27 | if (!exists) {
28 | db.knex.schema.createTable('dogs', function(dog) {
29 | // structure of dog db object to be fleshed out further
30 | dog.increments('id').primary();
31 | dog.string('name');
32 | dog.foreign('userId').references('users.id');
33 | dog.timestamps();
34 | }).then(function(table) {
35 | console.log('Created Table: ', table);
36 | });
37 | }
38 | });
39 |
40 | db.knex.schema.hasTable('walkers')
41 | .then(function(exists) {
42 | if (!exists) {
43 | db.knex.schema.createTable('walkers', function(walker) {
44 | // structure of walker db object to be fleshed out further
45 | walker.increments('id').primary();
46 | walker.string('name');
47 | walker.foreign('userId').references('users.id');
48 | walker.timestamps();
49 | }).then(function(table) {
50 | console.log('Created Table: ', table);
51 | });
52 | }
53 | });
54 |
55 | module.exports = db;
56 |
--------------------------------------------------------------------------------
/client/app.js:
--------------------------------------------------------------------------------
1 | angular.module('doggyBook', [
2 | 'doggyBook.services',
3 | 'doggyBook.auth',
4 | 'doggyBook.profile',
5 | 'doggyBook.search',
6 | 'doggyBook.landing',
7 | 'ngRoute'
8 | ])
9 |
10 | .config(function ($routeProvider, $httpProvider) {
11 | $routeProvider
12 | .when('/landing', {
13 | templateUrl: 'landing.html',
14 | controller: 'LandingController'
15 | })
16 | .when('/signin', {
17 | templateUrl: 'auth/signin.html',
18 | controller: 'AuthController'
19 | })
20 | .when('/signup', {
21 | templateUrl: 'auth/signin.html',
22 | controller: 'AuthController'
23 | })
24 | .when('/profile', {
25 | templateUrl: 'profile/profile.html',
26 | controller: 'ProfController',
27 | authenticate: true
28 | })
29 | .when('/search', {
30 | templateUrl: 'dashboard/search.html',
31 | controller: 'SearchController',
32 | authenticate: true
33 | })
34 | .otherwise({
35 | redirectTo: '/landings '
36 | });
37 |
38 | $httpProvider.interceptors.push('AttachTokens');
39 | })
40 | .factory('AttachTokens', function ($window) {
41 |
42 | var attach = {
43 | request: function (object) {
44 | var jwt = $window.localStorage.getItem('com.doggybook');
45 | if (jwt) {
46 | object.headers['x-access-token'] = jwt;
47 | }
48 | object.headers['Allow-Control-Allow-Origin'] = '*';
49 | return object;
50 | }
51 | };
52 | return attach;
53 | })
54 | .run(function ($rootScope, $location, Auth) {
55 |
56 | $rootScope.$on('$routeChangeStart', function (evt, next, current) {
57 | if (next.$$route && next.$$route.authenticate && !Auth.isAuth()) {
58 | $location.path('/signin');
59 | }
60 | });
61 | });
62 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://waffle.io/req-raccoons/doggybook)
2 | # doggybook
3 |
4 | Connecting dogs with walkers
5 |
6 | # Contributors
7 |
8 | Please see our [contributing page](CONTRIBUTING.md) if you would like to add to this project.
9 |
10 | # Team
11 |
12 | [](https://github.com/kcbroomall) | [](https://github.com/mcfungster) | [](https://github.com/jinweilin8)
13 | ---|---|---
14 | [Kyle Cameron](https://github.com/kcbroomall) | [Kevin Fung](https://github.com/mcfungster) | [Jinwei Lin](https://github.com/jinweilin8)
15 |
16 |
17 | # License
18 |
19 | The MIT License (MIT)
20 |
21 | Copyright (c) 2017 [req-raccoons](https://github.com/req-raccoons)
22 |
23 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
24 |
25 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
26 |
27 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/client/services/services.js:
--------------------------------------------------------------------------------
1 | angular.module('doggyBook.services', [])
2 |
3 | .factory('Auth', function ($http, $location, $window) {
4 |
5 | var signin = function (user) {
6 | return $http({
7 | method: 'POST',
8 | url: '/api/signin',
9 | data: user
10 | })
11 | .then(function (resp) {
12 | return resp.data.token;
13 | });
14 | };
15 |
16 | var signup = function (user) {
17 | //note that we might need to combine this with Prof.newProf below
18 | return $http({
19 | method: 'POST',
20 | url: '/api/signup',
21 | data: user
22 | })
23 | .then(function (resp) {
24 | return resp.data.token;
25 | });
26 | };
27 |
28 | var isAuth = function () {
29 | return !!$window.localStorage.getItem('com.doggyBook');
30 | };
31 |
32 | var signout = function () {
33 | $window.localStorage.removeItem('com.doggyBook');
34 | $location.path('/signin');
35 | };
36 |
37 | return {
38 | signin: signin,
39 | signup: signup,
40 | isAuth: isAuth,
41 | signout: signout
42 | };
43 | })
44 |
45 | .factory('Prof', function ($http, $location, $window) {
46 | //prof factory skeleton ->
47 | var newProf = function (prof) {
48 | //this function should run with signup if we are inputting prof data there
49 | return $http({
50 | method: 'POST',
51 | url: '/api/prof',
52 | data: prof
53 | })
54 | .then(function (resp) {
55 | return resp;
56 | });
57 | };
58 |
59 | return {
60 | newProf: newProf
61 | }
62 |
63 | .factory('Search', function ($http, $location, $window) {
64 |
65 | var getAllUsers = function () {
66 | //this function should query all profs from DB, send to search.html and
67 | return $http({
68 | method: 'GET',
69 | url: '/api/search',
70 | data: query
71 | })
72 | .then(function (resp) {
73 | return resp;
74 | });
75 | };
76 |
77 | return {
78 | getAllUsers: getAllUsers
79 | };
80 | })
81 |
82 | .factory('Landing', function ($http, $location, $window) {
83 |
84 | var landingFunc = function () {
85 | //this function should just allow for rerouting between other
86 | return $http({
87 | method: 'GET',
88 | url: '/api/search',
89 | data: query
90 | })
91 | .then(function (resp) {
92 | return resp;
93 | });
94 | };
95 |
96 | return {
97 | landingFunc: landingFunc
98 | };
99 | });
100 |
--------------------------------------------------------------------------------
/server/controller/userController.js:
--------------------------------------------------------------------------------
1 | // var Q = require('q');
2 | // var jwt = require('jwt-simple');
3 | // var User = require('./userModel.js');
4 | //
5 | // var findUser = Q.nbind(User.findOne, User);
6 | // var createUser = Q.nbind(User.create, User);
7 | //
8 | // //this needs to be refactored for mySQL or sqlite; it's currently using mongoose
9 | // module.exports = {
10 | // signin: function (req, res, next) {
11 | // var username = req.body.username;
12 | // var password = req.body.password;
13 | //
14 | // findUser({username: username})
15 | // .then(function (user) {
16 | // if (!user) {
17 | // next(new Error('User does not exist'));
18 | // } else {
19 | // return user.comparePasswords(password)
20 | // .then(function (foundUser) {
21 | // if (foundUser) {
22 | // var token = jwt.encode(user, 'secret');
23 | // res.json({token: token});
24 | // } else {
25 | // return next(new Error('No user'));
26 | // }
27 | // });
28 | // }
29 | // })
30 | // .fail(function (error) {
31 | // next(error);
32 | // });
33 | // },
34 | //
35 | // signup: function (req, res, next) {
36 | // var username = req.body.username;
37 | // var password = req.body.password;
38 | //
39 | // findUser({username: username})
40 | // .then(function (user) {
41 | // if (user) {
42 | // next(new Error('User already exist!'));
43 | // } else {
44 | // return createUser({
45 | // username: username,
46 | // password: password
47 | // });
48 | // }
49 | // })
50 | // .then(function (user) {
51 | // var token = jwt.encode(user, 'secret');
52 | // res.json({token: token});
53 | // })
54 | // .fail(function (error) {
55 | // next(error);
56 | // });
57 | // },
58 | //
59 | // checkAuth: function (req, res, next) {
60 | // var token = req.headers['x-access-token'];
61 | // if (!token) {
62 | // next(new Error('No token'));
63 | // } else {
64 | // var user = jwt.decode(token, 'secret');
65 | // findUser({username: user.username})
66 | // .then(function (foundUser) {
67 | // if (foundUser) {
68 | // res.send(200);
69 | // } else {
70 | // res.send(401);
71 | // }
72 | // })
73 | // .fail(function (error) {
74 | // next(error);
75 | // });
76 | // }
77 | // }
78 | // };
79 |
--------------------------------------------------------------------------------
/server/handlers.js:
--------------------------------------------------------------------------------
1 | var request = require('request');
2 |
3 | var db = require('../app/config');
4 | var jwt = require('jwt-simple');
5 |
6 |
7 | var User = require('../app/models/user');
8 | var Dog = require('../app/models/dog');
9 | var Walker = require('../app/models/walker');
10 |
11 | var Users = require('../app/collections/users');
12 | var Dogs = require('../app/collections/dogs');
13 | var Walkers = require('../app/collections/walkers');
14 |
15 |
16 | exports.signin = function(req, res) {
17 | console.log('signing in!');
18 | console.log('req.body: ', req.body);
19 |
20 | var username = req.body.username;
21 | var email = req.body.email;
22 | var password = req.body.password;
23 |
24 | // search the db for a particular username
25 | new User({username: username})
26 | .fetch()
27 | .then(function(user) {
28 | if (!user) {
29 | // if !found, redirect to sign in
30 | console.log('user not found, redirecting to landing page or sign in page');
31 | res.redirect('/api/signin');
32 | } else {
33 | // if found: hash the pw attempt against the stored pw
34 | user.comparePassword(password, function(match) {
35 | if (match) {
36 | // if matched, redirect to landing page/dashboard and authenticate
37 | console.log('authenticate user + start a session');
38 | res.redirect('/');
39 |
40 | } else {
41 | // if mismatched, send back to login page
42 | console.log('wrong password, redirecting to landing page or sign in page');
43 | res.redirect('/signin');
44 | }
45 | });
46 | }
47 | });
48 | }
49 |
50 | exports.signup = function(req, res) {
51 | // we'll be given some obj with data to be parsed and entered into the db.
52 | console.log('attempting a signup!');
53 | console.log('req.body: ', req.body);
54 |
55 | var username = req.body.username;
56 | var email = req.body.email;
57 | var password = req.body.password;
58 |
59 | new User({username: username})
60 | .fetch()
61 | .then(function(user) {
62 | // check if the provided username exists in the db
63 | // if found: send back an error
64 | if (user) {
65 | console.log("username already exists");
66 | res.redirect('/signup');
67 | }
68 | // if !found: register the user into TWO tables,
69 | // the general user table and the dog/walker table
70 | // dog/walker table must be created asynchronously!
71 | // the user table will take a hashed version of the desired pw.
72 | else {
73 | console.log('signing up the new user!');
74 | var newUser = new User({
75 | username: username,
76 | password: this.hashPassword(password),
77 | email: req.body.email,
78 | isDog: req.body.isDog,
79 | });
80 |
81 | console.log('made a new user!');
82 | newUser.save()
83 | .then(function(newUser) {
84 | console.log(newUser);
85 | if (newUser.get(isDog)) {
86 | var newDog = new Dog();
87 | } else {
88 | var newWalker = new Walker();
89 | }
90 | });
91 | }
92 | });
93 | }
94 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.
4 |
5 | Please note we have a code of conduct, please follow it in all your interactions with the project.
6 |
7 | # Pull Request Process
8 |
9 | Ensure any install or build dependencies are removed before the end of the layer when doing a build.
10 | Update the README.md with details of changes to the interface, this includes new environment variables, exposed ports, useful file locations and container parameters.
11 | Increase the version numbers in any examples files and the README.md to the new version that this Pull Request would represent.
12 | You may merge the Pull Request in once you have the sign-off of two other developers, or if you do not have permission to do that, you may request the second reviewer to merge it for you.
13 |
14 | # Code of Conduct
15 |
16 | ## Our Pledge
17 |
18 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
19 |
20 | ## Our Standards
21 |
22 | Examples of behavior that contributes to creating a positive environment include:
23 |
24 | Using welcoming and inclusive language
25 | Being respectful of differing viewpoints and experiences
26 | Gracefully accepting constructive criticism
27 | Focusing on what is best for the community
28 | Showing empathy towards other community members
29 | Examples of unacceptable behavior by participants include:
30 |
31 | The use of sexualized language or imagery and unwelcome sexual attention or advances
32 | Trolling, insulting/derogatory comments, and personal or political attacks
33 | Public or private harassment
34 | Publishing others' private information, such as a physical or electronic address, without explicit permission
35 | Other conduct which could reasonably be considered inappropriate in a professional setting
36 | Our Responsibilities
37 |
38 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
41 |
42 | ## Scope
43 |
44 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
45 |
46 | ## Enforcement
47 |
48 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
49 |
50 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
51 |
52 | ## Attribution
53 |
54 | This Code of Conduct is adapted from the Contributor Covenant, version 1.4, available at http://contributor-covenant.org/version/1/4
--------------------------------------------------------------------------------