From c45fc8ac005616cd9d1baa5687c9c3d8b4c15fdb Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Tue, 30 Apr 2013 00:19:49 +0200 Subject: changed loginbutton for facebook/twitter --- views/navbar.ejs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/views/navbar.ejs b/views/navbar.ejs index 6bc2bbe..c432055 100644 --- a/views/navbar.ejs +++ b/views/navbar.ejs @@ -6,10 +6,10 @@
<% if (!loggedin) { %> -- cgit v1.2.3 From a3d3af7a06369c5584ba4a94b8a79c936515de62 Mon Sep 17 00:00:00 2001 From: Erling Aaby Date: Tue, 30 Apr 2013 08:57:00 +0200 Subject: test --- public/css/use.less | 3 +++ 1 file changed, 3 insertions(+) diff --git a/public/css/use.less b/public/css/use.less index 4f2dbb9..21fd841 100644 --- a/public/css/use.less +++ b/public/css/use.less @@ -137,6 +137,9 @@ margin:60px; line-height: 26px; display: block; } + +#dildo +{} #hvor { height:460px; margin-top: 25px; -- cgit v1.2.3 From 344f400be5acfc28059a90834487081251b7cc67 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Tue, 30 Apr 2013 09:06:05 +0200 Subject: moved #vertical and removed use.less completely from shame.less --- public/css/shame.less | 12 +++++++++++- public/css/use.less | 14 +------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/public/css/shame.less b/public/css/shame.less index 04e4aa6..997409b 100644 --- a/public/css/shame.less +++ b/public/css/shame.less @@ -239,5 +239,15 @@ div.lastactivity .activity .details { } } +#vertical(@startColor: #555, @endColor: #333) { + background-color: mix(@startColor, @endColor, 60%); + background-image: -moz-linear-gradient(top, @startColor, @endColor); // FF 3.6+ + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(@startColor), to(@endColor)); // Safari 4+, Chrome 2+ + background-image: -webkit-linear-gradient(top, @startColor, @endColor); // Safari 5.1+, Chrome 10+ + background-image: -o-linear-gradient(top, @startColor, @endColor); // Opera 11.10 + background-image: linear-gradient(to bottom, @startColor, @endColor); // Standard, IE10 + background-repeat: repeat-x; + filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",argb(@startColor),argb(@endColor))); // IE9 and down +} + -/*@import "use.less";*/ diff --git a/public/css/use.less b/public/css/use.less index 21fd841..329f56d 100644 --- a/public/css/use.less +++ b/public/css/use.less @@ -2,18 +2,6 @@ width:100%; background-position: center 40%; }*/ - -#vertical(@startColor: #555, @endColor: #333) { - background-color: mix(@startColor, @endColor, 60%); - background-image: -moz-linear-gradient(top, @startColor, @endColor); // FF 3.6+ - background-image: -webkit-gradient(linear, 0 0, 0 100%, from(@startColor), to(@endColor)); // Safari 4+, Chrome 2+ - background-image: -webkit-linear-gradient(top, @startColor, @endColor); // Safari 5.1+, Chrome 10+ - background-image: -o-linear-gradient(top, @startColor, @endColor); // Opera 11.10 - background-image: linear-gradient(to bottom, @startColor, @endColor); // Standard, IE10 - background-repeat: repeat-x; - filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",argb(@startColor),argb(@endColor))); // IE9 and down -} - .content { margin-left: 0px; } @@ -191,4 +179,4 @@ margin:60px; background-color: #0D56A6; width:1170px; height:100px; -}*/ \ No newline at end of file +}*/ -- cgit v1.2.3 From 257bf2623479db39e2a32f2257ea02b113756e7e Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Tue, 30 Apr 2013 09:09:12 +0200 Subject: changed port AGAIN --- app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.js b/app.js index 492f8fe..f9aa1b9 100644 --- a/app.js +++ b/app.js @@ -10,7 +10,7 @@ var express = require('express') /** * App configuration */ -var port = process.env.PORT || 8001 +var port = process.env.PORT || 8000 , env = process.env.NODE_ENV || 'development' , config = require('./config/config')[env] , auth = require('./config/middlewares/authorization'); -- cgit v1.2.3 From f93cd061359f9060976d8209a0cc37d42b295edf Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Tue, 30 Apr 2013 09:09:55 +0200 Subject: working with project listing --- controllers/system.js | 19 ++++++++++++++----- views/dashboard.ejs | 4 +++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/controllers/system.js b/controllers/system.js index e3a55bd..6bd9d22 100644 --- a/controllers/system.js +++ b/controllers/system.js @@ -54,11 +54,17 @@ exports.faq = function(req, res) { exports.dashboard = function(req, res) { console.log('/dashboard - ' + req.user); - res.render('dashboard', { - title: 'kanin', - loggedin: true + + Project.find(function(err, projects) { + if (err) return res.render('500'); + console.log(projects); + res.render('dashboard', { + title: 'Dashboad', + loggedin: true, + projects: projects + }); }); -}; +} @@ -73,7 +79,10 @@ exports.newProject = function(req, res) { exports.postNewProject = function(req, res) { var project = new Project(req.body); project.save(function(err) { - if (err) return res.render('newproject', { title: 'Nytt prosjekt - en feil oppstod', loggedin: true, errors: err.errors, project: project }); + if (err) { + console.log(err.errors); + return res.render('newproject', { title: 'Nytt prosjekt - en feil oppstod', loggedin: true, errors: err.errors, project: project }); + } return res.redirect('/dashboard'); }); } diff --git a/views/dashboard.ejs b/views/dashboard.ejs index 5eca9f1..a1f625a 100644 --- a/views/dashboard.ejs +++ b/views/dashboard.ejs @@ -12,10 +12,11 @@

Prosjekter

+ <% projects.forEach(function(project) { %>
-

dennisse/hytteturskogentilfrank

+

dennisse/<%= project.name %>

Meg, Robert, Turid-Laila, Kurt, Stian, Aleksander, Frank, Olav, Heidi, Anette, Kristine @@ -30,6 +31,7 @@
+ <% }); %>
-- cgit v1.2.3 From acbdbe45a76a2d7b93fe565d43cd9760fa6e2e71 Mon Sep 17 00:00:00 2001 From: Erling Aaby Date: Tue, 30 Apr 2013 09:12:06 +0200 Subject: Fixed desktop images for divid home --- public/img/dashboard.png | Bin 127906 -> 128952 bytes public/img/dashboard@2x.png | Bin 339575 -> 342282 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/public/img/dashboard.png b/public/img/dashboard.png index 1b82ffc..0fdbc1f 100644 Binary files a/public/img/dashboard.png and b/public/img/dashboard.png differ diff --git a/public/img/dashboard@2x.png b/public/img/dashboard@2x.png index 4f582b8..b154265 100644 Binary files a/public/img/dashboard@2x.png and b/public/img/dashboard@2x.png differ -- cgit v1.2.3 From d9adc8029baee3eebec8ec809e13ae867132b8f0 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Tue, 30 Apr 2013 09:58:35 +0200 Subject: Added accessscema for project access --- models/access.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 models/access.js diff --git a/models/access.js b/models/access.js new file mode 100644 index 0000000..486ef5d --- /dev/null +++ b/models/access.js @@ -0,0 +1,28 @@ + +/** + * Module dependencies + */ + +var mongoose = require('mongoose') + , Schema = mongoose.Schema; + +var AccessSchema = new Schema({ + user: { type: String, ref: 'User' }, + creator: { type: String, ref: 'User' }, + project: { type: String, ref: 'Project' }, + permissions: { type: Number, default: '3' }, + created: { type: Date, default: Date.now }, + updated: { type: Date, default: Date.now } +}); + +// the four validations below only apply if you are signing up traditionally + +ProjectSchema.methods = { + + log: function() { + console.log('wat. wat logged this'); + } + +} + +mongoose.model('Access', AccessSchema); -- cgit v1.2.3 From 72de8d59b5ece58183eb65f0707e7fdf4d2d7f28 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Tue, 30 Apr 2013 10:12:12 +0200 Subject: you now need to log in to see the dashboard --- router.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/router.js b/router.js index b67f03a..ae94779 100644 --- a/router.js +++ b/router.js @@ -50,7 +50,7 @@ module.exports = function(app, passport, auth) { */ - app.get('/dashboard', system.dashboard); + app.get('/dashboard', auth.requiresLogin, system.dashboard); app.get('/project', auth.requiresLogin, system.project); -- cgit v1.2.3 From 2a0dfb6928d30213fc539a5ce8a4718bb9c383d8 Mon Sep 17 00:00:00 2001 From: Erling Aaby Date: Tue, 30 Apr 2013 10:32:05 +0200 Subject: Changed icon mouseovers for Divid home --- public/img/androidA.png | Bin 5772 -> 12586 bytes public/img/androidA@2x.png | Bin 5059 -> 28174 bytes public/img/iphoneA.png | Bin 4283 -> 13721 bytes public/img/iphoneA@2x.png | Bin 5906 -> 35316 bytes public/img/winA.png | Bin 5296 -> 7287 bytes public/img/winA@2x.png | Bin 4678 -> 19201 bytes 6 files changed, 0 insertions(+), 0 deletions(-) diff --git a/public/img/androidA.png b/public/img/androidA.png index a0c2f94..910e2a5 100644 Binary files a/public/img/androidA.png and b/public/img/androidA.png differ diff --git a/public/img/androidA@2x.png b/public/img/androidA@2x.png index 5b80fd9..9df89ba 100644 Binary files a/public/img/androidA@2x.png and b/public/img/androidA@2x.png differ diff --git a/public/img/iphoneA.png b/public/img/iphoneA.png index 3d35eaf..bd6956f 100644 Binary files a/public/img/iphoneA.png and b/public/img/iphoneA.png differ diff --git a/public/img/iphoneA@2x.png b/public/img/iphoneA@2x.png index a341671..d8e2967 100644 Binary files a/public/img/iphoneA@2x.png and b/public/img/iphoneA@2x.png differ diff --git a/public/img/winA.png b/public/img/winA.png index b19d985..7395c40 100644 Binary files a/public/img/winA.png and b/public/img/winA.png differ diff --git a/public/img/winA@2x.png b/public/img/winA@2x.png index 638145e..bbe34b3 100644 Binary files a/public/img/winA@2x.png and b/public/img/winA@2x.png differ -- cgit v1.2.3 From 64394b06c07d5009a4c9557822e64f19e06bdef9 Mon Sep 17 00:00:00 2001 From: Erling Aaby Date: Tue, 30 Apr 2013 11:45:34 +0200 Subject: Changed icon mouseovers for Divid Home --- public/img/androidA.png | Bin 12586 -> 9055 bytes public/img/androidA@2x.png | Bin 28174 -> 22383 bytes public/img/iphoneA.png | Bin 13721 -> 9785 bytes public/img/iphoneA@2x.png | Bin 35316 -> 27306 bytes public/img/winA.png | Bin 7287 -> 6468 bytes public/img/winA@2x.png | Bin 19201 -> 16853 bytes 6 files changed, 0 insertions(+), 0 deletions(-) diff --git a/public/img/androidA.png b/public/img/androidA.png index 910e2a5..afb53f9 100644 Binary files a/public/img/androidA.png and b/public/img/androidA.png differ diff --git a/public/img/androidA@2x.png b/public/img/androidA@2x.png index 9df89ba..204c8d0 100644 Binary files a/public/img/androidA@2x.png and b/public/img/androidA@2x.png differ diff --git a/public/img/iphoneA.png b/public/img/iphoneA.png index bd6956f..0e0399a 100644 Binary files a/public/img/iphoneA.png and b/public/img/iphoneA.png differ diff --git a/public/img/iphoneA@2x.png b/public/img/iphoneA@2x.png index d8e2967..e519291 100644 Binary files a/public/img/iphoneA@2x.png and b/public/img/iphoneA@2x.png differ diff --git a/public/img/winA.png b/public/img/winA.png index 7395c40..62bdb33 100644 Binary files a/public/img/winA.png and b/public/img/winA.png differ diff --git a/public/img/winA@2x.png b/public/img/winA@2x.png index bbe34b3..cdb2313 100644 Binary files a/public/img/winA@2x.png and b/public/img/winA@2x.png differ -- cgit v1.2.3 From 305e189956e8c4834300c8b5b38509590e70be7f Mon Sep 17 00:00:00 2001 From: Erling Aaby Date: Tue, 30 Apr 2013 12:16:39 +0200 Subject: changes in divid home and use.less --- public/css/use.less | 6 ++---- views/home.ejs | 19 ++++--------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/public/css/use.less b/public/css/use.less index 329f56d..7512bfb 100644 --- a/public/css/use.less +++ b/public/css/use.less @@ -37,6 +37,7 @@ padding: 5px; } .infobox { + display: inline-block; text-align: center; /*background-color: @grayLighter;*/ @@ -104,6 +105,7 @@ margin-top:45px; .scenario { margin:60px; +text-align: center; } /* @@ -111,12 +113,8 @@ margin:60px; background-color:@grayLighter; }*/ #hva { - height:460px; margin-top: 25px; /*border-top: 2px solid #9fd5df;*/ - - color: #000000; - background-color: #eeeeee; box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2); -moz-box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.2); -webkit-box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.2); diff --git a/views/home.ejs b/views/home.ejs index 7884df8..2539f2a 100644 --- a/views/home.ejs +++ b/views/home.ejs @@ -78,7 +78,6 @@

Parforhold

I etableringsfasen som ønsker å ha ordnet økonomi fra starten av

-

Hindrer snylting

@@ -88,11 +87,6 @@

Hvem betaler hva for hans, hennes og deres barn?

-
@@ -122,20 +116,15 @@

Registrering

"Her skal registreringsformen inn"

-

Divid er enkelt!

- -- cgit v1.2.3 From afd9ee0713c1f6deca72d7223d8cbe178e45831e Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Tue, 30 Apr 2013 12:24:59 +0200 Subject: made the dashboard list actice projects --- views/dashboard.ejs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/views/dashboard.ejs b/views/dashboard.ejs index a1f625a..66dfa80 100644 --- a/views/dashboard.ejs +++ b/views/dashboard.ejs @@ -12,26 +12,26 @@

Prosjekter

- <% projects.forEach(function(project) { %> -
-
-
-

dennisse/<%= project.name %>

-
-
- Meg, Robert, Turid-Laila, Kurt, Stian, Aleksander, Frank, Olav, Heidi, Anette, Kristine -
-
- Oppgjør: -200 kr + <% projects.forEach(function(projects) { %> +
+
+
+

<%= projects.project.user.username %>/<%= projects.project.name %>

+
+
+ Meg, Robert, Turid-Laila, Kurt, Stian, Aleksander, Frank, Olav, Heidi, Anette, Kristine +
+
+ Oppgjør: -200 kr +
+
+

+

+
-
-

+

-
-
-
- <% }); %> +
+ <% }); %>
-- cgit v1.2.3 From f51fa5f8d2c29e0bccd13bf287f917aeb121ee5c Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Tue, 30 Apr 2013 12:25:23 +0200 Subject: made a function for returning all accesses for a user including their projects --- models/access.js | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/models/access.js b/models/access.js index 486ef5d..ab8d257 100644 --- a/models/access.js +++ b/models/access.js @@ -7,9 +7,9 @@ var mongoose = require('mongoose') , Schema = mongoose.Schema; var AccessSchema = new Schema({ - user: { type: String, ref: 'User' }, - creator: { type: String, ref: 'User' }, - project: { type: String, ref: 'Project' }, + user: { type: Schema.ObjectId, ref: 'User' }, + creator: { type: Schema.ObjectId, ref: 'User' }, + project: { type: Schema.ObjectId, ref: 'Project' }, permissions: { type: Number, default: '3' }, created: { type: Date, default: Date.now }, updated: { type: Date, default: Date.now } @@ -17,12 +17,27 @@ var AccessSchema = new Schema({ // the four validations below only apply if you are signing up traditionally -ProjectSchema.methods = { +AccessSchema.statics = { log: function() { console.log('wat. wat logged this'); + }, + + /** + * Load ALL accesses for a single user + * + * @param {ObjectId} id + * @param {Function} callback + * @api private + */ + + loadUser: function(id, callback) { + this.find({ user: id }) + .populate('user') + .populate('project') + .sort({ 'created': -1 }) // sort by date + .exec(callback); } - } mongoose.model('Access', AccessSchema); -- cgit v1.2.3 From 334cdccec27afcb1a353df49f7edb77181048843 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Tue, 30 Apr 2013 12:25:44 +0200 Subject: made a function for returning project by ID --- models/project.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/models/project.js b/models/project.js index 2424694..2641fe5 100644 --- a/models/project.js +++ b/models/project.js @@ -6,12 +6,8 @@ var mongoose = require('mongoose') , Schema = mongoose.Schema; - - - - var ProjectSchema = new Schema({ - user: { type: String, ref: 'User' }, + user: { type: Schema.ObjectId, ref: 'User' }, name: { type: String, default: '', trim: true }, description: {type: String, default: '', trim: true }, currency: { type: String, default: 'kr', trim: true }, @@ -20,7 +16,6 @@ var ProjectSchema = new Schema({ updated: { type: Date, default: Date.now } }); - // the four validations below only apply if you are signing up traditionally ProjectSchema.path('name').validate(function(name) { @@ -28,12 +23,29 @@ ProjectSchema.path('name').validate(function(name) { return name.length; }, 'Project name cannot be blank'); -ProjectSchema.methods = { +ProjectSchema.statics = { log: function() { console.log('wat. wat logged this'); + }, + + + + /** + * Find project by id + * + * @param {ObjectId} id + * @param {Function} callback + * @api private + */ + + load: function(id, callback) { + this.findOne({ _id: id }) + .populate('user') + .exec(callback); } + } mongoose.model('Project', ProjectSchema); -- cgit v1.2.3 From ecee8a7e9ce62d36c11318c49f403a859a0b04e1 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Tue, 30 Apr 2013 12:26:04 +0200 Subject: made the dashboard work somewhat better --- controllers/system.js | 56 ++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 7 deletions(-) diff --git a/controllers/system.js b/controllers/system.js index 6bd9d22..ad5ced0 100644 --- a/controllers/system.js +++ b/controllers/system.js @@ -3,9 +3,9 @@ * Module dependencies */ var mongoose = require('mongoose') - , Project = mongoose.model('Project'); - - + , Project = mongoose.model('Project') + , Access = mongoose.model('Access') + , User = mongoose.model('User'); /** @@ -53,17 +53,46 @@ exports.faq = function(req, res) { exports.dashboard = function(req, res) { - console.log('/dashboard - ' + req.user); + console.log('/dashboard - ' + req.user._id); + +/* + Access.find({ user: req.user._id }, function(err, accesses) { + if (err) return res.render('500'); + console.log('accesses ' + accesses); + accesses.forEach(function(access) { + Project.load(access.project, function(err, project) { + if (err) return res.render('500'); + projectList.push(project); + console.log(project.user.username); + }); + }); + }); +*/ + Access.loadUser(req.user._id, function(err, projects) { + if (err) return res.render('500'); + Project.populate(projects, { path: 'project.user', model: User }, function(err, projects) { + + console.log('accesses: ' + projects); + + res.render('dashboard', { + title: 'Dashboard', + loggedin: true, + projects: projects + }); + }); + + }) + +/* Project.find(function(err, projects) { if (err) return res.render('500'); - console.log(projects); res.render('dashboard', { title: 'Dashboad', loggedin: true, projects: projects }); - }); + });*/ } @@ -78,12 +107,25 @@ exports.newProject = function(req, res) { exports.postNewProject = function(req, res) { var project = new Project(req.body); + project.user = req.user._id; project.save(function(err) { if (err) { console.log(err.errors); return res.render('newproject', { title: 'Nytt prosjekt - en feil oppstod', loggedin: true, errors: err.errors, project: project }); } - return res.redirect('/dashboard'); }); + + var access = new Access(); + access.user = req.user._id; + access.creator = req.user._id; + access.project = project._id; + access.permissions = 1; + access.save(function(err) { + if (err) { + console.log(err.errors); + return res.render('newproject', { title: 'Nytt prosjekt - en feil oppstod', loggedin: true }); + } + return res.redirect('/dashboard'); + }) } -- cgit v1.2.3 From a5dc6c364609f9d26d9086cc6f792d8cee934283 Mon Sep 17 00:00:00 2001 From: Erling Aaby Date: Tue, 30 Apr 2013 12:34:05 +0200 Subject: changes in use.less --- public/css/use.less | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/public/css/use.less b/public/css/use.less index 7512bfb..740818f 100644 --- a/public/css/use.less +++ b/public/css/use.less @@ -1,10 +1,10 @@ /*#wrapper { width:100%; background-position: center 40%; -}*/ +} .content { margin-left: 0px; -} +}*/ .pitch { position: relative; margin-left: 10px; @@ -25,13 +25,11 @@ float: left; margin-top: 20px; margin-left: 10px; - margin-right: 0px; + margin-right: 20px; } .sectionright { float: right; - margin-top: 20px; - margin-right: 10px; - margin-left: 0px; + margin: 20px; } .tutorial { padding: 5px; @@ -77,7 +75,7 @@ margin-top:45px; } .showcase { - height: 460px; + /*height: 460px;*/ margin-top: 40px; margin-bottom: 20px; margin-left: 0px; @@ -113,12 +111,14 @@ text-align: center; background-color:@grayLighter; }*/ #hva { + /*height: 460px;*/ + /*margin: 0 auto;*/ margin-top: 25px; /*border-top: 2px solid #9fd5df;*/ box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2); -moz-box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.2); -webkit-box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.2); - margin: 0 auto; + font-size: 18px; line-height: 26px; display: block; @@ -127,7 +127,7 @@ text-align: center; #dildo {} #hvor { - height:460px; + /*height:460px;*/ margin-top: 25px; /*border-top: 2px solid #9fd5df;*/ @@ -136,13 +136,13 @@ text-align: center; box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2); -moz-box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.2); -webkit-box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.2); - margin: 0 auto; + /*margin: 0 auto;*/ font-size: 18px; line-height: 26px; display: block; } #hvordan { - height:460px; + /*height:460px;*/ margin-top: 25px; /*border-top: 2px solid #9fd5df;*/ @@ -151,7 +151,7 @@ text-align: center; box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2); -moz-box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.2); -webkit-box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.2); - margin: 0 auto; + /*margin: 0 auto;*/ font-size: 18px; line-height: 26px; display: block; @@ -168,7 +168,7 @@ text-align: center; box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2); -moz-box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.2); -webkit-box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.2); - margin: 0 auto; + /*margin: 0 auto;*/ font-size: 18px; line-height: 26px; display: block; -- cgit v1.2.3 From 68503c27b6a4ea3c9dee7d97e64a5792aa26214f Mon Sep 17 00:00:00 2001 From: Erling Aaby Date: Tue, 30 Apr 2013 13:01:21 +0200 Subject: Changed img for pairs in divid home --- public/img/fest@2x.png | Bin 4389 -> 0 bytes public/img/par.png | Bin 6545 -> 3453 bytes public/img/par@2x.png | Bin 5110 -> 3900 bytes 3 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 public/img/fest@2x.png diff --git a/public/img/fest@2x.png b/public/img/fest@2x.png deleted file mode 100644 index 748ae2f..0000000 Binary files a/public/img/fest@2x.png and /dev/null differ diff --git a/public/img/par.png b/public/img/par.png index 5b9beb2..3637a8e 100644 Binary files a/public/img/par.png and b/public/img/par.png differ diff --git a/public/img/par@2x.png b/public/img/par@2x.png index 1797663..6c15675 100644 Binary files a/public/img/par@2x.png and b/public/img/par@2x.png differ -- cgit v1.2.3 From 9c06210e54b596140f0814da195b5fe37b44a2d2 Mon Sep 17 00:00:00 2001 From: Erling Aaby Date: Tue, 30 Apr 2013 13:02:19 +0200 Subject: Added fest@2x.png because of wrong deletion --- public/img/fest@2x.png | Bin 0 -> 4389 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 public/img/fest@2x.png diff --git a/public/img/fest@2x.png b/public/img/fest@2x.png new file mode 100644 index 0000000..748ae2f Binary files /dev/null and b/public/img/fest@2x.png differ -- cgit v1.2.3 From c0630c6db730ba50ab247435bff14a36a4303e93 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Tue, 30 Apr 2013 13:28:45 +0200 Subject: added shorturl for projects --- models/project.js | 18 +++++++++++++++++- views/dashboard.ejs | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/models/project.js b/models/project.js index 2641fe5..f29c7f8 100644 --- a/models/project.js +++ b/models/project.js @@ -13,7 +13,8 @@ var ProjectSchema = new Schema({ currency: { type: String, default: 'kr', trim: true }, public: { type: String, default: 'invite-only' }, created: { type: Date, default: Date.now }, - updated: { type: Date, default: Date.now } + updated: { type: Date, default: Date.now }, + shortURL: { type: String, unique: true } }); // the four validations below only apply if you are signing up traditionally @@ -23,6 +24,21 @@ ProjectSchema.path('name').validate(function(name) { return name.length; }, 'Project name cannot be blank'); + +ProjectSchema.pre('save', function(next) { + if (this.shortURL !== undefined) return next(); + var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; + this.shortURL = ''; + for (var i = 0; i < 6; i++) { + var x = Math.floor(Math.random() * chars.length); + this.shortURL += chars.charAt(x); + } + console.log('SHORT: ' + this.shortURL); + next(); +}); + + + ProjectSchema.statics = { log: function() { diff --git a/views/dashboard.ejs b/views/dashboard.ejs index 66dfa80..dfd76f6 100644 --- a/views/dashboard.ejs +++ b/views/dashboard.ejs @@ -16,7 +16,7 @@
-

<%= projects.project.user.username %>/<%= projects.project.name %>

+

<%= projects.project.user.username %>/<%= projects.project.name %>

Meg, Robert, Turid-Laila, Kurt, Stian, Aleksander, Frank, Olav, Heidi, Anette, Kristine -- cgit v1.2.3 From 698e59e4426448c2a0c55efb55f8cacb22ce3909 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Tue, 30 Apr 2013 13:29:10 +0200 Subject: removed .populate('user') when we already know the user --- models/access.js | 1 - 1 file changed, 1 deletion(-) diff --git a/models/access.js b/models/access.js index ab8d257..ce75f8c 100644 --- a/models/access.js +++ b/models/access.js @@ -33,7 +33,6 @@ AccessSchema.statics = { loadUser: function(id, callback) { this.find({ user: id }) - .populate('user') .populate('project') .sort({ 'created': -1 }) // sort by date .exec(callback); -- cgit v1.2.3 From 7ef5bc29e6032ae9f7318ae5790e45057f7e5b4f Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Tue, 30 Apr 2013 13:31:00 +0200 Subject: renamed router to routes as it now contains more static routes, than actually working as a router --- app.js | 2 +- routes.js | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 routes.js diff --git a/app.js b/app.js index f9aa1b9..618ef8d 100644 --- a/app.js +++ b/app.js @@ -44,7 +44,7 @@ require('./config/express')(app, config, passport); /** * Routes */ -require('./router')(app, passport, auth); +require('./routes')(app, passport, auth); /** diff --git a/routes.js b/routes.js new file mode 100644 index 0000000..ae94779 --- /dev/null +++ b/routes.js @@ -0,0 +1,61 @@ + +/** + * Dependencies + */ + +var users = require('./controllers/users') + , system = require('./controllers/system'); + + +/* + * ============================================================ + * Routes + * + */ + +module.exports = function(app, passport, auth) { + app.get('/', system.index); + + app.get('/test', system.test); + + app.get('/home', system.home); + + app.get('/faq', system.faq); + + app.get('/login', users.login); + + app.get('/signup', users.signup); + + app.post('/signup', users.create); + + + app.post('/test', users.signin); + + app.get('/auth/facebook', passport.authenticate('facebook', { failureRedirect: '/test' }), users.signin); + + app.get('/auth/facebook/callback', passport.authenticate('facebook', { failureRedirect: '/test' }), function(req, res) { + console.log('/auth/facebook/callback --- ' + req.user.username); + res.redirect('/dashboard'); + }); + + app.get('/auth/twitter', passport.authenticate('twitter', { failureRedirect: '/test' }), users.signin); + app.get('/auth/twitter/callback', passport.authenticate('twitter', { failureRedirect: '/test' }), users.authCallback); + + app.get('/logout', users.logout); + + + /** + * REQUIRES LOGIN + * ============================================================ + */ + + + app.get('/dashboard', auth.requiresLogin, system.dashboard); + + + app.get('/project', auth.requiresLogin, system.project); + + app.get('/project/new', auth.requiresLogin, system.newProject); + + app.post('/project/new', auth.requiresLogin, system.postNewProject) +}; -- cgit v1.2.3 From 3a59f59037fbe8cdd51e5ce52c83ea70e1a973cb Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Tue, 30 Apr 2013 13:32:14 +0200 Subject: removed old router --- router.js | 61 ------------------------------------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 router.js diff --git a/router.js b/router.js deleted file mode 100644 index ae94779..0000000 --- a/router.js +++ /dev/null @@ -1,61 +0,0 @@ - -/** - * Dependencies - */ - -var users = require('./controllers/users') - , system = require('./controllers/system'); - - -/* - * ============================================================ - * Routes - * - */ - -module.exports = function(app, passport, auth) { - app.get('/', system.index); - - app.get('/test', system.test); - - app.get('/home', system.home); - - app.get('/faq', system.faq); - - app.get('/login', users.login); - - app.get('/signup', users.signup); - - app.post('/signup', users.create); - - - app.post('/test', users.signin); - - app.get('/auth/facebook', passport.authenticate('facebook', { failureRedirect: '/test' }), users.signin); - - app.get('/auth/facebook/callback', passport.authenticate('facebook', { failureRedirect: '/test' }), function(req, res) { - console.log('/auth/facebook/callback --- ' + req.user.username); - res.redirect('/dashboard'); - }); - - app.get('/auth/twitter', passport.authenticate('twitter', { failureRedirect: '/test' }), users.signin); - app.get('/auth/twitter/callback', passport.authenticate('twitter', { failureRedirect: '/test' }), users.authCallback); - - app.get('/logout', users.logout); - - - /** - * REQUIRES LOGIN - * ============================================================ - */ - - - app.get('/dashboard', auth.requiresLogin, system.dashboard); - - - app.get('/project', auth.requiresLogin, system.project); - - app.get('/project/new', auth.requiresLogin, system.newProject); - - app.post('/project/new', auth.requiresLogin, system.postNewProject) -}; -- cgit v1.2.3 From c0c20e4d6672223014d8caa9e31ed5bb966762c1 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Tue, 30 Apr 2013 13:43:10 +0200 Subject: added routes for projects and the participantpage --- routes.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/routes.js b/routes.js index ae94779..0b6bd65 100644 --- a/routes.js +++ b/routes.js @@ -57,5 +57,9 @@ module.exports = function(app, passport, auth) { app.get('/project/new', auth.requiresLogin, system.newProject); - app.post('/project/new', auth.requiresLogin, system.postNewProject) + app.post('/project/new', auth.requiresLogin, system.postNewProject); + + app.get('/project/:short', auth.requiresLogin, system.project); + + app.get('/project/:short/participants', auth.requiresLogin, system.projectParticipants); }; -- cgit v1.2.3 From 691b1eb84e1bcae1d97d49b96a25961b694fa9f4 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Tue, 30 Apr 2013 13:48:18 +0200 Subject: added post-route for participants --- routes.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/routes.js b/routes.js index 0b6bd65..d597ae8 100644 --- a/routes.js +++ b/routes.js @@ -62,4 +62,6 @@ module.exports = function(app, passport, auth) { app.get('/project/:short', auth.requiresLogin, system.project); app.get('/project/:short/participants', auth.requiresLogin, system.projectParticipants); + + app.post('/project/:short/participants', auth.requiresLogin, system.postProjectParticipants); }; -- cgit v1.2.3 From 6f63c6c1960930509c998031eb6dc855ec6f4f5e Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Tue, 30 Apr 2013 13:52:36 +0200 Subject: added for participantpage --- controllers/system.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/controllers/system.js b/controllers/system.js index ad5ced0..5400173 100644 --- a/controllers/system.js +++ b/controllers/system.js @@ -101,6 +101,17 @@ exports.project = function(req, res) { res.render('project', { title: 'Harepus', loggedin: true }); } +exports.projectParticipants = function(req, res) { + + res.render('projectParticipants', { title: 'Prosjektdeltakere', loggedin: true }); + +} + +exports.postProjectParticipants = function(req, res) { + +} + + exports.newProject = function(req, res) { res.render('newproject', { title: 'Nytt prosjekt', loggedin: true }); } -- cgit v1.2.3 From c505aaa0e21f7e0b11f8cb384ddd613fa3669014 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Tue, 30 Apr 2013 14:37:10 +0200 Subject: made a page for adding participants to projects --- views/projectParticipants.ejs | 55 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 views/projectParticipants.ejs diff --git a/views/projectParticipants.ejs b/views/projectParticipants.ejs new file mode 100644 index 0000000..3af9c10 --- /dev/null +++ b/views/projectParticipants.ejs @@ -0,0 +1,55 @@ +<% include header %> + + + + <% include navbar %> + + +
+
+ + +
+
+ +

<%= title %>

+

Her kan du invitere venner til å delta i prosjektet ditt. Skriv inn eposadressene deres, en på hver linje, i tekstboksen under.

+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ + +
+
+ +
+
+ + + + + + + +
+
+ + +<% include footer %> + + -- cgit v1.2.3 From 67172b7b82a2e36b101f371a608abdab7dac91bb Mon Sep 17 00:00:00 2001 From: Erling Aaby Date: Tue, 30 Apr 2013 14:40:30 +0200 Subject: Added img and new sub html contact.ejs --- public/img/dennis.jpg | Bin 0 -> 28716 bytes public/img/erling.jpg | Bin 0 -> 30651 bytes public/img/robert.jpg | Bin 0 -> 29892 bytes public/img/stian.jpg | Bin 0 -> 23693 bytes views/contact.ejs | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 73 insertions(+) create mode 100644 public/img/dennis.jpg create mode 100644 public/img/erling.jpg create mode 100644 public/img/robert.jpg create mode 100644 public/img/stian.jpg create mode 100644 views/contact.ejs diff --git a/public/img/dennis.jpg b/public/img/dennis.jpg new file mode 100644 index 0000000..9e86a1c Binary files /dev/null and b/public/img/dennis.jpg differ diff --git a/public/img/erling.jpg b/public/img/erling.jpg new file mode 100644 index 0000000..97e499e Binary files /dev/null and b/public/img/erling.jpg differ diff --git a/public/img/robert.jpg b/public/img/robert.jpg new file mode 100644 index 0000000..f4c0a69 Binary files /dev/null and b/public/img/robert.jpg differ diff --git a/public/img/stian.jpg b/public/img/stian.jpg new file mode 100644 index 0000000..2b6ce31 Binary files /dev/null and b/public/img/stian.jpg differ diff --git a/views/contact.ejs b/views/contact.ejs new file mode 100644 index 0000000..bf43f1c --- /dev/null +++ b/views/contact.ejs @@ -0,0 +1,73 @@ +<% include header %> + + + + + + <% include navbar %> + + +
+
+ +
+
+
+

Kontakt oss

+

Support

+

Se gjerne igjennom vår faq - ofte stilte spørsmål - før dere sender mail på support(a)divid.no . +

Business

+

Ønsker du å kontakte oss for kjøp av annonseplass, forretninger og lignende ta kontakt på pr(a)divid.no.

+
+
+

Om teamet DERS

+
+

Dennis Eriksen

+ +

Alder:

+

Ifra:Skien

+

Mobil:

+

Fokus:

+

Favoritt ting:Unicorns

+

+
+

Erling Aaby

+ +

Alder:

+

Ifra:Oslo

+

Mobil:

+

Fokus:

+

Favoritt ting:trening

+

+
+

Robert Joramo

+ +

Alder:

+

Ifra:Årnes

+

Mobil:

+

Fokus:

+

Favoritt ting:Fopal

+

+
+

Stian Olsen

+ +

Alder:

+

Ifra:Trondheim

+

Mobil:

+

Fokus:

+

Favoritt ting:Korboi <3

+

+
+
+
+
+
+ +<% include footer %> + + \ No newline at end of file -- cgit v1.2.3 From d556ef525f593ccb8c688e340f70659849ac74a3 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Tue, 30 Apr 2013 14:41:30 +0200 Subject: renamed files to match model names --- controllers/system.js | 2 + models/Access.js | 42 +++++++++++++++++ models/Project.js | 67 ++++++++++++++++++++++++++ models/User.js | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++ models/access.js | 42 ----------------- models/project.js | 67 -------------------------- models/user.js | 128 -------------------------------------------------- 7 files changed, 239 insertions(+), 237 deletions(-) create mode 100644 models/Access.js create mode 100644 models/Project.js create mode 100644 models/User.js delete mode 100644 models/access.js delete mode 100644 models/project.js delete mode 100644 models/user.js diff --git a/controllers/system.js b/controllers/system.js index 5400173..a5e8f46 100644 --- a/controllers/system.js +++ b/controllers/system.js @@ -109,6 +109,8 @@ exports.projectParticipants = function(req, res) { exports.postProjectParticipants = function(req, res) { + + } diff --git a/models/Access.js b/models/Access.js new file mode 100644 index 0000000..ce75f8c --- /dev/null +++ b/models/Access.js @@ -0,0 +1,42 @@ + +/** + * Module dependencies + */ + +var mongoose = require('mongoose') + , Schema = mongoose.Schema; + +var AccessSchema = new Schema({ + user: { type: Schema.ObjectId, ref: 'User' }, + creator: { type: Schema.ObjectId, ref: 'User' }, + project: { type: Schema.ObjectId, ref: 'Project' }, + permissions: { type: Number, default: '3' }, + created: { type: Date, default: Date.now }, + updated: { type: Date, default: Date.now } +}); + +// the four validations below only apply if you are signing up traditionally + +AccessSchema.statics = { + + log: function() { + console.log('wat. wat logged this'); + }, + + /** + * Load ALL accesses for a single user + * + * @param {ObjectId} id + * @param {Function} callback + * @api private + */ + + loadUser: function(id, callback) { + this.find({ user: id }) + .populate('project') + .sort({ 'created': -1 }) // sort by date + .exec(callback); + } +} + +mongoose.model('Access', AccessSchema); diff --git a/models/Project.js b/models/Project.js new file mode 100644 index 0000000..f29c7f8 --- /dev/null +++ b/models/Project.js @@ -0,0 +1,67 @@ + +/** + * Module dependencies + */ + +var mongoose = require('mongoose') + , Schema = mongoose.Schema; + +var ProjectSchema = new Schema({ + user: { type: Schema.ObjectId, ref: 'User' }, + name: { type: String, default: '', trim: true }, + description: {type: String, default: '', trim: true }, + currency: { type: String, default: 'kr', trim: true }, + public: { type: String, default: 'invite-only' }, + created: { type: Date, default: Date.now }, + updated: { type: Date, default: Date.now }, + shortURL: { type: String, unique: true } +}); + +// the four validations below only apply if you are signing up traditionally + +ProjectSchema.path('name').validate(function(name) { + // if you're authenticated by any of the oauth strategies (facebook, twitter), don't validate + return name.length; +}, 'Project name cannot be blank'); + + +ProjectSchema.pre('save', function(next) { + if (this.shortURL !== undefined) return next(); + var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; + this.shortURL = ''; + for (var i = 0; i < 6; i++) { + var x = Math.floor(Math.random() * chars.length); + this.shortURL += chars.charAt(x); + } + console.log('SHORT: ' + this.shortURL); + next(); +}); + + + +ProjectSchema.statics = { + + log: function() { + console.log('wat. wat logged this'); + }, + + + + /** + * Find project by id + * + * @param {ObjectId} id + * @param {Function} callback + * @api private + */ + + load: function(id, callback) { + this.findOne({ _id: id }) + .populate('user') + .exec(callback); + } + + +} + +mongoose.model('Project', ProjectSchema); diff --git a/models/User.js b/models/User.js new file mode 100644 index 0000000..b61f7c9 --- /dev/null +++ b/models/User.js @@ -0,0 +1,128 @@ + +/** + * Module dependencies + */ + +var mongoose = require('mongoose') + , Schema = mongoose.Schema + , crypto =require('crypto') + , authTypes = ['facebook', 'twitter']; + + +/** + * User schema + */ + +var UserSchema = new Schema({ + name: String, + email: String, + username: String, + provider: String, + hashed_password: String, + salt: String, + facebook: {}, + twitter: {} +}); + +/** + * Virtuals + */ + +UserSchema + .virtual('password') + .set(function(password) { + this._password = password + this.salt = this.makeSalt() + this.hashed_password = this.encryptPassword(password) + }).get(function() { return this._password }); + +/** + * Validations + */ +var validatePrecenceOf = function (value) { + return value && value.length; +} + +// the four validations below only apply if you are signing up traditionally + +UserSchema.path('name').validate(function(name) { + // if you're authenticated by any of the oauth strategies (facebook, twitter), don't validate + if(authTypes.indexOf(this.provider) !== -1) return true; + return name.length; +}, 'Name cannot be blank'); + +UserSchema.path('email').validate(function(email) { + if(authTypes.indexOf(this.provider) !== -1) return true; + return email.length; +}, 'Email cannot be blank'); + +UserSchema.path('username').validate(function(username) { + if(authTypes.indexOf(this.provider) !== -1) return true; + return username.length; +}, 'Username cannot be blank'); + +UserSchema.path('hashed_password').validate(function(hashed_password) { + if(authTypes.indexOf(this.provider) !== -1) return true; + return hashed_password.length; +}, 'Password cannot be blank'); + +/** + * Pre-save hook + */ + +UserSchema.pre('save', function(next) { + if (!this.isNew) return next(); + + if(!validatePrecenceOf(this.password) + && authTypes.indexOf(this.provider) === -1) + next(new Error('Invalid password')); + else next(); +}); + + +/** + * Methods + */ + +UserSchema.methods = { + + /** + * Authenticate - check if passwords are the same + * + * @param {String} plainText + * @return {Bolean} + * @api public + */ + + authenticate: function(plainText) { + return this.encryptPassword(plainText) === this.hashed_password; + }, + + /** + * Make salt + * + * @return {String} + * @api public + */ + + makeSalt: function() { + return Math.round((new Date().valueOf() * Math.random())) + ''; + }, + + /** + * Encrypt password + * + * @param {String} password + * @return {String} + * @api public + */ + + encryptPassword: function(password) { + if (!password) return ''; + return crypto.createHmac('sha1', this.salt).update(password).digest('hex'); + } +} + +mongoose.model('User', UserSchema); + + diff --git a/models/access.js b/models/access.js deleted file mode 100644 index ce75f8c..0000000 --- a/models/access.js +++ /dev/null @@ -1,42 +0,0 @@ - -/** - * Module dependencies - */ - -var mongoose = require('mongoose') - , Schema = mongoose.Schema; - -var AccessSchema = new Schema({ - user: { type: Schema.ObjectId, ref: 'User' }, - creator: { type: Schema.ObjectId, ref: 'User' }, - project: { type: Schema.ObjectId, ref: 'Project' }, - permissions: { type: Number, default: '3' }, - created: { type: Date, default: Date.now }, - updated: { type: Date, default: Date.now } -}); - -// the four validations below only apply if you are signing up traditionally - -AccessSchema.statics = { - - log: function() { - console.log('wat. wat logged this'); - }, - - /** - * Load ALL accesses for a single user - * - * @param {ObjectId} id - * @param {Function} callback - * @api private - */ - - loadUser: function(id, callback) { - this.find({ user: id }) - .populate('project') - .sort({ 'created': -1 }) // sort by date - .exec(callback); - } -} - -mongoose.model('Access', AccessSchema); diff --git a/models/project.js b/models/project.js deleted file mode 100644 index f29c7f8..0000000 --- a/models/project.js +++ /dev/null @@ -1,67 +0,0 @@ - -/** - * Module dependencies - */ - -var mongoose = require('mongoose') - , Schema = mongoose.Schema; - -var ProjectSchema = new Schema({ - user: { type: Schema.ObjectId, ref: 'User' }, - name: { type: String, default: '', trim: true }, - description: {type: String, default: '', trim: true }, - currency: { type: String, default: 'kr', trim: true }, - public: { type: String, default: 'invite-only' }, - created: { type: Date, default: Date.now }, - updated: { type: Date, default: Date.now }, - shortURL: { type: String, unique: true } -}); - -// the four validations below only apply if you are signing up traditionally - -ProjectSchema.path('name').validate(function(name) { - // if you're authenticated by any of the oauth strategies (facebook, twitter), don't validate - return name.length; -}, 'Project name cannot be blank'); - - -ProjectSchema.pre('save', function(next) { - if (this.shortURL !== undefined) return next(); - var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; - this.shortURL = ''; - for (var i = 0; i < 6; i++) { - var x = Math.floor(Math.random() * chars.length); - this.shortURL += chars.charAt(x); - } - console.log('SHORT: ' + this.shortURL); - next(); -}); - - - -ProjectSchema.statics = { - - log: function() { - console.log('wat. wat logged this'); - }, - - - - /** - * Find project by id - * - * @param {ObjectId} id - * @param {Function} callback - * @api private - */ - - load: function(id, callback) { - this.findOne({ _id: id }) - .populate('user') - .exec(callback); - } - - -} - -mongoose.model('Project', ProjectSchema); diff --git a/models/user.js b/models/user.js deleted file mode 100644 index b61f7c9..0000000 --- a/models/user.js +++ /dev/null @@ -1,128 +0,0 @@ - -/** - * Module dependencies - */ - -var mongoose = require('mongoose') - , Schema = mongoose.Schema - , crypto =require('crypto') - , authTypes = ['facebook', 'twitter']; - - -/** - * User schema - */ - -var UserSchema = new Schema({ - name: String, - email: String, - username: String, - provider: String, - hashed_password: String, - salt: String, - facebook: {}, - twitter: {} -}); - -/** - * Virtuals - */ - -UserSchema - .virtual('password') - .set(function(password) { - this._password = password - this.salt = this.makeSalt() - this.hashed_password = this.encryptPassword(password) - }).get(function() { return this._password }); - -/** - * Validations - */ -var validatePrecenceOf = function (value) { - return value && value.length; -} - -// the four validations below only apply if you are signing up traditionally - -UserSchema.path('name').validate(function(name) { - // if you're authenticated by any of the oauth strategies (facebook, twitter), don't validate - if(authTypes.indexOf(this.provider) !== -1) return true; - return name.length; -}, 'Name cannot be blank'); - -UserSchema.path('email').validate(function(email) { - if(authTypes.indexOf(this.provider) !== -1) return true; - return email.length; -}, 'Email cannot be blank'); - -UserSchema.path('username').validate(function(username) { - if(authTypes.indexOf(this.provider) !== -1) return true; - return username.length; -}, 'Username cannot be blank'); - -UserSchema.path('hashed_password').validate(function(hashed_password) { - if(authTypes.indexOf(this.provider) !== -1) return true; - return hashed_password.length; -}, 'Password cannot be blank'); - -/** - * Pre-save hook - */ - -UserSchema.pre('save', function(next) { - if (!this.isNew) return next(); - - if(!validatePrecenceOf(this.password) - && authTypes.indexOf(this.provider) === -1) - next(new Error('Invalid password')); - else next(); -}); - - -/** - * Methods - */ - -UserSchema.methods = { - - /** - * Authenticate - check if passwords are the same - * - * @param {String} plainText - * @return {Bolean} - * @api public - */ - - authenticate: function(plainText) { - return this.encryptPassword(plainText) === this.hashed_password; - }, - - /** - * Make salt - * - * @return {String} - * @api public - */ - - makeSalt: function() { - return Math.round((new Date().valueOf() * Math.random())) + ''; - }, - - /** - * Encrypt password - * - * @param {String} password - * @return {String} - * @api public - */ - - encryptPassword: function(password) { - if (!password) return ''; - return crypto.createHmac('sha1', this.salt).update(password).digest('hex'); - } -} - -mongoose.model('User', UserSchema); - - -- cgit v1.2.3 From e3170f61056cadd493b32c249f5a00b5d7996229 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Tue, 30 Apr 2013 14:45:44 +0200 Subject: added testlink --- views/project.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/project.ejs b/views/project.ejs index 4bee9fd..e9978d5 100644 --- a/views/project.ejs +++ b/views/project.ejs @@ -35,7 +35,7 @@ Robert Joramo
Dennis Eriksen
Helene Apelort
- Legg til flere deltakere + Legg til flere deltakere
-- cgit v1.2.3 From c97de0454c16ae883d9237e5b3fb292e282af53e Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Wed, 1 May 2013 10:59:02 +0200 Subject: better logging --- app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.js b/app.js index 618ef8d..a0f7ae1 100644 --- a/app.js +++ b/app.js @@ -20,7 +20,7 @@ mongoose.connect(config.db); var db = mongoose.connection; db.on('error', console.error.bind(console, 'connection error:')); db.once('open', function callback(){ - console.log('Connected to MongoDB'); + console.log('Connected to ' + config.db); }); // Bootstrap models -- cgit v1.2.3 From a935f29043c48063839c5f139dbbde6817b213f6 Mon Sep 17 00:00:00 2001 From: Dennis Eriksen Date: Wed, 1 May 2013 11:25:43 +0200 Subject: added generateRandomAccessToken method --- models/User.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/models/User.js b/models/User.js index b61f7c9..4d32941 100644 --- a/models/User.js +++ b/models/User.js @@ -5,7 +5,7 @@ var mongoose = require('mongoose') , Schema = mongoose.Schema - , crypto =require('crypto') + , crypto = require('crypto') , authTypes = ['facebook', 'twitter']; @@ -20,6 +20,7 @@ var UserSchema = new Schema({ provider: String, hashed_password: String, salt: String, + accessToken: String, facebook: {}, twitter: {} }); @@ -98,6 +99,7 @@ UserSchema.methods = { return this.encryptPassword(plainText) === this.hashed_password; }, + /** * Make salt * @@ -109,6 +111,7 @@ UserSchema.methods = { return Math.round((new Date().valueOf() * Math.random())) + ''; }, + /** * Encrypt password * @@ -120,6 +123,24 @@ UserSchema.methods = { encryptPassword: function(password) { if (!password) return ''; return crypto.createHmac('sha1', this.salt).update(password).digest('hex'); + }, + + + /** + * Generate random access token for Remember Me function + * + * @return {String} + * @api public + */ + + generateRandomToken: function() { + var chars = "_!abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" + , token = new Date().getTime() + '_'; + for (var i = 0; i < 16; i++) { + var x = Math.floor(Math.random() * 62); + token += chars.charAt(x); + } + return token; } } -- cgit v1.2.3