Permalink
Browse files

adding route for authentication

  • Loading branch information...
1 parent 010e84a commit 365c04c8df3af9a54356bf6ac6e46d2d6f6f6faf @scottcowan scottcowan committed Oct 22, 2011
Showing with 11 additions and 12 deletions.
  1. +6 −12 security.js
  2. +5 −0 services.js
View
@@ -4,21 +4,15 @@ encryption = require('./encryption');
exports.validateUser = function(req, res, next) {
var cookies = new Cookies( req, res );
- var username = cookies.get( "username" );
+ var session_cookie = cookies.get( "ymindsid" );
- if(!username) {
+ if(!session_cookie) {
res.json({ success: false}, {}, 401);
}
- else next();
-};
-
-exports.currentUser = function(req, res) {
- var cookies = new Cookies( req, res );
- try {
- var username = cookies.get( "username" );
- return username;
- } catch (ex) {
- return null;
+ else{
+ //TODO: session db validation
+ console.log(session_cookie);
+ next();
}
};
View
@@ -16,6 +16,11 @@ exports.init = function(app) {
app.use(express.static(__dirname + '/site'));
});
+ app.get('*',function(req,res){
+ //if(security)
+ //console.log("bam");
+ });
+
app.post('/login', function(req, res){
security.signInUser(req, res, req.body.email, req.body.password, function(result,session_id,name) {
if(!result){

0 comments on commit 365c04c

Please sign in to comment.