/**
 * playSessionCheck
 *
 * @module      :: Policy
 * @description :: Allow any user logged in from Play
 * @docs        :: http://sailsjs.org/#!documentation/policies
 *
 */
module.exports = function(req, res, next) {

  if (new PlaySession(req).isValid()) {
    sails.log.debug("checking Play session cookie... OK");
    req.session.authenticated = true;
  } else {
    sails.log.debug("checking Play session cookie... NO");
  }

  return next();
};

@@ -221,12 +221,26 @@
 %0A%0A  
-if (
+var playSession = 
 new 
@@ -259,22 +259,117 @@
 req)
-.isValid()) %7B%0A
+;%0A  if (playSession.isValid()) %7B%0A    User.findOne(%7Bemail: playSession.email()%7D).exec(function(err, user) %7B%0A  
     
@@ -381,33 +381,24 @@
 .log.debug(%22
-checking 
 Play session
@@ -402,24 +402,37 @@
 ion 
-cookie... OK%22
+is valid: %22 + user.email
 );%0A
+  
     
@@ -465,16 +465,76 @@
 = true;%0A
+      req.session.user = user %7C%7C %7B%7D;%0A      next();%0A    %7D);%0A%0A
   %7D else
@@ -561,17 +561,8 @@
 ug(%22
-checking 
 Play
@@ -574,37 +574,35 @@
 ion 
-cookie... NO%22);%0A  %7D%0A%0A  return
+is invalid or absent%22);%0A   
  nex
@@ -606,11 +606,15 @@
 next();%0A
+  %7D%0A
 %7D;%0A

store user data in session