Skip to content

Commit

Permalink
Patch _register.
Browse files Browse the repository at this point in the history
  • Loading branch information
martindale committed Mar 22, 2016
1 parent b1fa022 commit 89b54f9
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions components/identity.jade
Original file line number Diff line number Diff line change
Expand Up @@ -137,26 +137,29 @@ dom-module#maki-identity
_register: function() {
var self = this;
console.log('[MAKI:IDENTITY]', '_register');
self._publish();
// TODO: use purely local store
$.ajax({
type: 'POST',
url: '/people',
data: {
name: self.identity.name,
_identity: self.identity.key.public
},
headers: {
Accept: 'application/json'
},
success: function(data, res) {
console.log('[MAKI:IDENTITY]', '_register result:', res);
}
self._publish(function() {
// TODO: use purely local store
$.ajax({
type: 'POST',
url: '/people',
data: {
name: self.identity.name,
identity: self.identity.key.public,
_identity: self.identity._id
},
headers: {
Accept: 'application/json'
},
success: function(data, res) {
console.log('[MAKI:IDENTITY]', '_register result:', res);
}
});
});
},
_publish: function() {
_publish: function(cb) {
var self = this;
console.log('[MAKI:IDENTITY]', '_publish');
if (!cb) cb = new Function();

var clone = _.cloneDeep(self.identity);
delete clone.seed;
Expand All @@ -172,6 +175,8 @@ dom-module#maki-identity
},
success: function(data) {
console.log('[MAKI:IDENTITY]', 'published:', data);
self.identity._id = data._id;
cb();
}
});

Expand Down

0 comments on commit 89b54f9

Please sign in to comment.