aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/controllers
diff options
context:
space:
mode:
authorDennis Eriksen <dennis.se@gmail.com>2013-04-29 09:16:00 +0200
committerDennis Eriksen <dennis.se@gmail.com>2013-04-29 09:16:00 +0200
commitdd061b09ae345a272810984335cc84281b0c87ce (patch)
treeb7c6d40673d3452a4a1456ba9370eca1cec986f1 /controllers
parentWrong location for img (diff)
parentcleaning (diff)
downloadDivid-dd061b09ae345a272810984335cc84281b0c87ce.tar.gz
Merge branch 'dev'
Conflicts: app.js router.js
Diffstat (limited to 'controllers')
-rw-r--r--controllers/system.js62
-rw-r--r--controllers/users.js67
2 files changed, 129 insertions, 0 deletions
diff --git a/controllers/system.js b/controllers/system.js
new file mode 100644
index 0000000..e54fc1c
--- /dev/null
+++ b/controllers/system.js
@@ -0,0 +1,62 @@
+
+/**
+ * Module dependencies
+ */
+
+
+
+
+
+/**
+ * Before the user log in
+ * ===============================================================
+*/
+
+exports.index = function(req, res) {
+ res.render('index', { title: 'DERS' });
+ };
+
+
+
+exports.test = function(req, res) {
+ res.render('test', {
+ title: 'test',
+ loggedin: false
+ });
+ };
+
+
+exports.home = function(req, res) {
+ res.render('home', {
+ title: 'home',
+ loggedin: false
+ });
+ };
+
+
+
+
+
+
+
+/**
+ * After the user has logged in
+ * ===============================================================
+*/
+
+
+
+exports.dashboard = function(req, res) {
+ console.log('/dashboard - ' + req.user);
+ res.render('dashboard', {
+ title: 'kanin',
+ loggedin: true
+ });
+ };
+
+
+
+exports.project = function(req, res) {
+ res.render('project', { title: 'Harepus', loggedin: true });
+}
+
diff --git a/controllers/users.js b/controllers/users.js
new file mode 100644
index 0000000..d465468
--- /dev/null
+++ b/controllers/users.js
@@ -0,0 +1,67 @@
+
+/**
+ * Module dependencies
+ */
+
+var mongoose = require('mongoose')
+ , User = mongoose.model('User');
+
+/**
+ * Login
+ */
+exports.login = function(req, res) {
+ res.render('login', {
+ title: 'Login'
+ });
+
+}
+
+
+/**
+ * Logout
+ */
+exports.logout = function(req, res) {
+ req.logout();
+ res.resirect('/test');
+}
+
+
+/**
+ * Signin
+ * This is triggered when the user post to /login
+ */
+exports.signin = function(req, res) {}
+
+
+/**
+ * Signup
+ */
+exports.signup = function(req, res) {
+ res.render('signup', { title: 'Registrer deg' });
+}
+
+/**
+ * Create users
+ */
+exports.create = function(req, res) {
+ var user = new User(req.body);
+ user.provider = 'local';
+ user.save(function(err) {
+ if (err) return res.render('/signup', { errors: err.errors, user: user });
+ req.logIn(user, function(err) {
+ if (err) return next(err);
+ return res.redirect('/dashboard');
+ });
+ });
+}
+
+
+/**
+ * AuthCallback
+ * This is what happends when a user has signed in using facebook/twitter
+ */
+
+exports.authCallback = function(req, res, next) {
+ res.redirect('/dashboard');
+}
+