Skip to content

Commit

Permalink
submission with personal web page link
Browse files Browse the repository at this point in the history
  • Loading branch information
Nisha Vaity authored and Nisha Vaity committed Nov 30, 2016
1 parent b143194 commit e9dffc3
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 4 deletions.
24 changes: 24 additions & 0 deletions assignment/services/user.service.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,37 @@ module.exports = function(app,model){


//console.log("Inside user service server js");
app.post('/api/login', login);
app.get('/api/user', findUser);
// app.get('/api/user?username=username&password=password',findUserByCredentials);
app.get('/api/user/:userId',findUserById);
app.post('/api/user',createUser);
app.put('/api/user/:userId',updateUser);
app.delete('/api/user/:userId',deleteUser);


function login(req, res) {
var user = req.body;
var username, password;
username = user.username;
password = user.password;

model
.userModel
.findUserByCredentials(username, password)
.then(
function (user) {
if(user)
res.json(user);
else
res.send('0');
},
function (error) {
res.sendStatus(400).send(error);
}
);
}

function createUser(req, res) {
var user = req.body;
// user._id = (new Date().getTime()).toString();
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@
"main": "server.js",
"dependencies": {
"body-parser": "^1.15.1",
"cookie-parser": "^1.4.3",
"express": "^4.13.4",
"express-session": "^1.14.2",
"http": "0.0.0",
"mongoose": "^4.4.15",
"multer": "^1.2.0",
"passport": "^0.3.2",
"passport-facebook": "^2.1.1",
"passport-google-oauth": "^1.0.0",
"passport-local": "^1.0.0"
},
"devDependencies": {},
Expand Down
13 changes: 12 additions & 1 deletion public/assignment/services/user.service.client.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,21 @@
findUserByUsername : findUserByUsername,
findUserByCredentials : findUserByCredentials,
updateUser : updateUser,
deleteUser : deleteUser
deleteUser : deleteUser,
login:login

};
return api;

function login(username, password) {
var user = {
username:username,
password:password
}

return $http.post("/api/login",user);
}

function createUser(user) {
//user.push(user);
//console.log(user);
Expand Down
3 changes: 2 additions & 1 deletion public/assignment/views/user/user.controller.client.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
function login(username,password){
// console.log(username);
// console.log(password);
var promise = UserService.findUserByCredentials(username,password);
var promise = UserService.login(username,password);
//var promise = UserService.findUserByCredentials(username,password);
promise
.success(function(user){
if(user === '0'){
Expand Down
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h2>Required links</h2>
<a href="project/index.html">Project</a>
</li>
<li>
<a href="personalPage/index.html">Assignment</a>
<a href="personalPage/index.html">Personal Web Page</a>
</li>
<li>
<a href="assignment/index.html">Assignment</a>
Expand Down
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var express = require('express');
var app = express();

var bodyParser = require('body-parser');
app.use(bodyParser.json());
app.use(bodyParser.json({type:'website/json'}));
app.use(bodyParser.urlencoded({ extended: true }));

// configure a public directory to host static content
Expand Down

0 comments on commit e9dffc3

Please sign in to comment.