Skip to content

Commit

Permalink
password encryption
Browse files Browse the repository at this point in the history
  • Loading branch information
TSN Student committed Jul 19, 2018
1 parent 591264e commit 79361bc
Show file tree
Hide file tree
Showing 25 changed files with 411 additions and 201 deletions.
93 changes: 81 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"lint": "ng lint",
"e2e": "ng e2e",
"postinstall": "ng build ---prod"

},
"private": true,
"dependencies": {
Expand All @@ -23,9 +22,14 @@
"@angular/platform-browser": "^5.2.0",
"@angular/platform-browser-dynamic": "^5.2.0",
"@angular/router": "^5.2.0",
"bcrypt-nodejs": "0.0.3",
"cookie-parser": "^1.4.3",
"core-js": "^2.4.1",
"express-session": "^1.15.6",
"mongoose": "^5.1.6",
"multer": "^1.3.0",
"passport": "^0.4.0",
"passport-local": "^1.0.0",
"rxjs": "^5.5.6",
"zone.js": "^0.8.19"
},
Expand Down
33 changes: 28 additions & 5 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,33 @@ const bodyParser = require('body-parser');
// http library allows us to create http servers
const http = require('http');
const path = require('path');

const cookieParser = require('cookie-parser');
const session = require('express-session');

app.use(cookieParser());

if(process.env.SESSION_SECRET) {
app.use(session({
secret: process.env.SESSION_SECRET,
resave: true,
saveUninitialized: true }));

} else {
app.use(session({
secret: 'test',
resave: true,
saveUninitialized: true}));

}



var passport = require('passport');

app.use(passport.initialize());
app.use(passport.session());

// Initialize bodyparser. We are turn on the feature to parse json data.
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
Expand All @@ -18,7 +45,7 @@ app.use(express.static(path.join(__dirname, 'dist')));
// CORS - Cross-Origin Resource Sharing
// For security purposes, browser only allowed client side to request data from its own server. CORS is a mechanism that determines whether to block or fulfill requests for restricted resources on a web page from another domain outside the domain from which the resource originated.
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Origin", "http://localhost:4200");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
res.header("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
res.header("Access-Control-Allow-Credentials", "true");
Expand All @@ -31,11 +58,7 @@ app.set('port', port);
// Create HTTP server
const server = http.createServer(app);

app.get("/h", hello);

function hello(req,res){
res.send("hello");
}
require('./server/app')(app);

// For Build: Catch all other routes and return the index file -- BUILDING
Expand Down
2 changes: 1 addition & 1 deletion server/models/website/website.model.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function findWebsiteById(wid) {
}

function findAllWebsitesForUser(uid) {
return WebsiteModel.find({developerId: uid});
return WebsiteModel.find({developerId: uid}).sort({name:1, description:1});
}


Expand Down
8 changes: 1 addition & 7 deletions server/models/widget/widget.schema.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,14 @@ var mongoose = require('mongoose')

var WidgetSchema = mongoose.Schema({
pageId: {type: mongoose.Schema.Types.ObjectId, ref: 'WebsiteModel'},
widgetType: String,
widgetType: {type: String, enum:['HEADING', 'IMAGE', 'YOUTUBE']},
name: String,
text: String,
placeholder: String,
description: String,
url: String,
width: String,
height: String,
rows: Number,
size: Number,
class: String,
icon: String,
deletable: Boolean,
formatted: Boolean,
dateCreated: {type: Date, default: Date.now}
}, {collection: 'widget'})

Expand Down
7 changes: 0 additions & 7 deletions server/services/page.service.server.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@

module.exports = function(app){
const pageModel = require('../models/page/page.model.server.js')
pages =
[
{ _id: "321", name: "Post 1", websiteId: "456", description: "Lorem" },
{ _id: "432", name: "Post 2", websiteId: "456", description: "Lorem" },
{ _id: "543", name: "Post 3", websiteId: "456", description: "Lorem" }
];

app.post('/api/website/:wid/page',createPage);
app.get('/api/website/:wid/page',findAllPagesForWebsite);
Expand Down
Loading

0 comments on commit 79361bc

Please sign in to comment.