var User = require('../models/users');


exports.index = function(req, res) {
	if (req.isAuthenticated()) {
		res.render('mytasks', { title: 'Task Kwetu | View Tasks', user: req.user });
		console.log(req.user);
	} else {
		res.render('index', { title: 'Task Kwetu' });
	}
};


exports.forgotPass = function(req, res) {
  res.render('fpassword', { title: 'Task Kwetu | Password Reset' });
};


exports.newTask = function(req, res) {
  res.render('newtask', { title: 'Task Kwetu | Create Task', user: req.user });
};


exports.myTasks = function(req, res) {
	User.get( req.user.id ).run(function(error, result) {
		if (result == null) {
			res.status(404).json({ "Error": "User Not Found" });
		}
		if (error) {
			res.status(500).json({ "error": "something blew up, we're fixing it" });
		}
		else {
			if (result.provider == 'local') {
				result.provider = false;
			} else { result.provider = true; }
			res.render('mytasks', { title: 'Task Kwetu | My Tasks', user: req.user, result: result });
		}
	});	
};


exports.myAccount = function(req, res) {
  	User.get( req.user.id ).run(function(error, result) {
		if (result == null) {
			res.status(404).json({ "Error": "User Not Found" });
		}
		if (error) {
			res.status(500).json({ "error": "something blew up, we're fixing it" });
		}
		else {
			if (result.provider == 'local') {
				result.provider = false;
			} else { result.provider = true; }
			res.render('myaccount', { title: 'Task Kwetu | My Account', user: req.user, result: result });
		}
	});
};


exports.support = function(req, res) {
  res.render('support', { title: 'Task Kwetu | support', user: req.user });
};


exports.login = function(req, res) {
  res.render('login', { title: 'Task Kwetu | Login' });
};


exports.signup = function(req, res) {
  res.render('signup', { title: 'Task Kwetu | Signup' });
};

@@ -101,16 +101,377 @@
 ed()) %7B%0A
+%0A%09%09User.get( req.user.id ).run(function(error, result) %7B%0A%09%09%09if (result == null) %7B%0A%09%09%09%09res.status(404).json(%7B %22Error%22: %22User Not Found%22 %7D);%0A%09%09%09%7D%0A%09%09%09if (error) %7B%0A%09%09%09%09res.status(500).json(%7B %22error%22: %22something blew up, we're fixing it%22 %7D);%0A%09%09%09%7D%0A%09%09%09else %7B%0A%09%09%09%09if (result.provider == 'local') %7B%0A%09%09%09%09%09result.provider = false;%0A%09%09%09%09%7D else %7B result.provider = true; %7D%0A%09%09
 %09%09res.re
@@ -513,12 +513,10 @@
 u %7C 
-View
+My
  Tas
@@ -538,38 +538,41 @@
 user
- %7D);%0A%09%09console.log(req.user
+, result: result %7D);%0A%09%09%09%7D%0A%09%09%7D
 );%0A
+%0A
 %09%7D e

fix home