You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I am using the register function on the controller updates are not being sent. I can see socket messages being pushed to the task object.
the register function is being called via HTTP POST instead of a socket call.
Task works, user does not.
User model:
varUser={// Enforce model schema in the case of schemaless databasesschema: true,attributes: {groups: {collection: 'groups',via: 'members',required: true},username : {type: 'string',unique: true,required: true},email : {type: 'email',unique: true,required: true},passports : {collection: 'Passport',via: 'user'}// Groups}};module.exports=User;
User controller:
/** * UserController * * @description :: Server-side logic for managing Users * @help :: See http://links.sailsjs.org/docs/controllers */module.exports={session: function(req,res){res.json({success: true});},//expose a method for angular to be able to see if we are logged inisLoggedIn: function(req,res){//TODO: make sure that only the clients with the right session get the broadcast//sails.sockets.broadcast("authNotification" , "authorized",{socketId: req.socket.id, user: req.user} ); res.json({sessionID: req.session.sessionID,roles: req.session.roles,user: req.user});//res.json(req.isAuthenticated() ? {sessionID: req.sessionID, user: req.user} : 0);},//expose a method for angular to be able to see if we are logged insayHi: function(req,res){sails.sockets.broadcast("authNotification","message",{message: "onLogin"});sails.sockets.broadcast("authNotification","message",{message: "hello3"});res.json({result:"sent"});},sendHello: function(req,res){//req.sessionIDsails.io.sockets.in('asdf').emit("eventName",{data:true});//sails.sockets.broadcast.to("asdf").emit('loggedOut', {loggedOff: 'true'});res.json({sessionid: req.sessionID,message: "sent"})},register: function(req,res){//associate groupGroups.findOrCreate({groupName: 'user'},{groupName: 'user',description: 'Generic user'}).exec(functioncreateFindCB(err,userGroup){//Check password for equalityvarpassword=req.param('password');varconfirmation=req.param('confirmation');//TODO: enfore better passsword enforcementif(!password){res.json({err: {message: "You must enter a password"}});}elseif(password==confirmation){varuserObj={username: req.param('username'),email: req.param('email'),groups: [userGroup.id]};//Create userUser.create(userObj,functionuserCreated(err,user){if(err){res.json({err: err});}else{//Associate passport ( password )//TODO: include other authentication mechanismsPassport.create({protocol: 'local',password: password,user: user.id},function(err,passport){if(err){User.destroy(user.id,functiondeleteCB(deleteErr){sails.log(deleteErr);});res.json({err:err});console.log(err);}else{res.json({success: true});}});}});}else{res.json({err: {message: "Passwords do not match"}});}});}};
The text was updated successfully, but these errors were encountered:
This might be an issue with Sails, or my configuration.
However in my controller I am binding:
When I am using the register function on the controller updates are not being sent. I can see socket messages being pushed to the task object.
the register function is being called via HTTP POST instead of a socket call.
Task works, user does not.
User model:
User controller:
The text was updated successfully, but these errors were encountered: