mirror of
https://github.com/mclueppers/xo-server.git
synced 2025-04-08 20:55:02 +02:00
Various updates.
This commit is contained in:
parent
16667e0d40
commit
c9cd1ebee2
@ -112,6 +112,8 @@ Collection.prototype.remove = function (ids) {
|
||||
delete this.models[id];
|
||||
}, this);
|
||||
|
||||
this.emit('remove', ids);
|
||||
|
||||
// @todo Maybe return a more meaningful value.
|
||||
/* jshint newcap: false */
|
||||
return Q(true);
|
||||
|
@ -66,7 +66,7 @@ function json_api_call(session, message)
|
||||
function (error) {
|
||||
if (error instanceof Error)
|
||||
{
|
||||
console.error(error);
|
||||
console.error(error.stack);
|
||||
return format_error(Api.err.SERVER_ERROR);
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ Model.prototype.get = function (property, def) {
|
||||
* Checks if a property exists.
|
||||
*/
|
||||
Model.prototype.has = function (property) {
|
||||
return (undefined !== this.get(property));
|
||||
return (undefined !== this.properties[property]);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -64,7 +64,6 @@ Model.prototype.set = function (properties, value) {
|
||||
|
||||
var model = this;
|
||||
_.each(properties, function (value, key) {
|
||||
|
||||
var prev = model.get(key);
|
||||
|
||||
// New value.
|
||||
|
@ -14,8 +14,8 @@ var Session = Model.extend({
|
||||
|
||||
// If the user associated to this session is deleted or
|
||||
// disabled, the session must close.
|
||||
this.on('change:user_id', function (user_id) {
|
||||
var event = 'user.revoked'+ user_id;
|
||||
this.on('change:user_id', function () {
|
||||
var event = 'user.revoked:'+ this.get('user_id');
|
||||
|
||||
xo.on(event, close);
|
||||
|
||||
@ -27,8 +27,8 @@ var Session = Model.extend({
|
||||
|
||||
// If the token associated to this session is deleted, the
|
||||
// session must close.
|
||||
this.on('change:token_id', function (token_id) {
|
||||
var event = 'token.revoked'+ token_id;
|
||||
this.on('change:token_id', function () {
|
||||
var event = 'token.revoked:'+ this.get('token_id');
|
||||
|
||||
xo.on(event, close);
|
||||
|
||||
|
11
src/xo.js
11
src/xo.js
@ -1,6 +1,8 @@
|
||||
var _ = require('underscore');
|
||||
var crypto = require('crypto');
|
||||
var hashy = require('hashy');
|
||||
var Q = require('q');
|
||||
|
||||
var Collection = require('./collection');
|
||||
var Model = require('./model');
|
||||
|
||||
@ -149,14 +151,15 @@ function Xo()
|
||||
|
||||
// This events are used to automatically close connections if the
|
||||
// associated credentials are invalidated.
|
||||
var self = this;
|
||||
this.tokens.on('remove', function (token_ids) {
|
||||
token_ids.each(function (token_id) {
|
||||
this.emit('token.revoked:'+ token_id);
|
||||
_.each(token_ids, function (token_id) {
|
||||
self.emit('token.revoked:'+ token_id);
|
||||
});
|
||||
});
|
||||
this.users.on('remove', function (user_ids) {
|
||||
user_ids.each(function (user_id) {
|
||||
this.emit('user.revoked:'+ user_id);
|
||||
_.each(user_ids, function (user_id) {
|
||||
self.emit('user.revoked:'+ user_id);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user