aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/controllers/users.js
diff options
context:
space:
mode:
authorDennis Eriksen <dennis.se@gmail.com>2013-04-29 03:39:15 +0200
committerDennis Eriksen <dennis.se@gmail.com>2013-04-29 03:39:15 +0200
commitfc50b5b7f18d02ffa8056dc1edbd3bd43e973493 (patch)
treee4646512634a42790bbddfec8b3d035bb2052cec /controllers/users.js
parentadded twitter authentication (diff)
downloadDivid-fc50b5b7f18d02ffa8056dc1edbd3bd43e973493.tar.gz
been cleaning a bit, moving stuff to where it belongs. signup and
signin works.
Diffstat (limited to 'controllers/users.js')
-rw-r--r--controllers/users.js62
1 files changed, 62 insertions, 0 deletions
diff --git a/controllers/users.js b/controllers/users.js
new file mode 100644
index 0000000..af454b5
--- /dev/null
+++ b/controllers/users.js
@@ -0,0 +1,62 @@
+
+/**
+ * Module dependencies
+ */
+
+var mongoose = require('mongoose')
+ , User = mongoose.model('User');
+
+/**
+ * Login
+ */
+
+exports.login = function(req, res) {
+ res.render('login', {
+ title: 'Login'
+ });
+
+}
+
+
+/**
+ * Logout
+ */
+
+exports.logoug = function(req, res) {
+ req.logout();
+ res.resirect('/test');
+}
+
+
+/**
+ * Signin
+ */
+
+exports.signin = function(req, res) {}
+
+/**
+ * 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');
+}
+