Binding doesn't work on some models possibly with HTTP POST
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- angular, javascript
- Domain
- backend, frontend, full-stack
Research direction
Start by reproducing the register HTTP POST using the shown $sailsBind bindings, then compare the socket updates received for the User and Task models. Inspect the User model associations and UserController.register flow shown in the issue. Done means the binding behavior is explained and User updates work consistently with Task updates, or the required configuration is documented.
Written by the indexing model from the issue text.
Description
This might be an issue with Sails, or my configuration.
However in my controller I am binding:
$sailsBind.bind("user", $scope)
$sailsBind.bind("task", $scope)
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:
var User = {
// Enforce model schema in the case of schemaless databases
schema: 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 in
isLoggedIn: 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 in
sayHi: 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.sessionID
sails.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 group
Groups.findOrCreate({
groupName: 'user'
}, {
groupName: 'user',
description: 'Generic user'
}).exec(function createFindCB(err, userGroup) {
//Check password for equality
var password = req.param('password');
var confirmation = req.param('confirmation');
//TODO: enfore better passsword enforcement
if(!password){
res.json({err: { message: "You must enter a password" }});
} else if (password == confirmation){
var userObj = {
username: req.param('username'),
email: req.param('email'),
groups: [userGroup.id]
};
//Create user
User.create(userObj, function userCreated(err, user) {
if (err) {
res.json({
err: err
});
} else {
//Associate passport ( password )
//TODO: include other authentication mechanisms
Passport.create({
protocol: 'local',
password: password,
user: user.id
}, function (err, passport) {
if (err){
User.destroy(user.id, function deleteCB(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" }});
}
});
}
};
- Dominant language
- JavaScript
- Stars
- 135
- Forks
- 23
- PR merge metrics
- No merged PRs in 30d
Getting set up
We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from diegopamio/angular-sails-bind
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
diegopamio/angular-sails-bind#34 · 1 comment ·
-
Set headers?Open
Difficulty 4/5 3-5 days Newbie friendliness 25/100
diegopamio/angular-sails-bind#33 · 1 comment ·
-
JSON objectsOpen0 - Backlog
Difficulty 3/5 1-2 days Newbie friendliness 28/100
diegopamio/angular-sails-bind#28 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
diegopamio/angular-sails-bind#23 · 1 comment ·
-
0 - Backlog
Difficulty 3/5 1-2 days Newbie friendliness 30/100
diegopamio/angular-sails-bind#20 · 5 comments ·
All issues in diegopamio/angular-sails-bind
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day
-
curriculum documentation quality
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
githubnext/gh-aw-workshop#3897 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
agent/quality hive/hosted-available-lke648397-260827-5n31 quality testing
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
Maintainers usually reply within 1 day