- Can now add a second email address to your account and delete one of your email addresses - Reset password now works - Resetting the password of an account without a password set will set one - Email templates overhauled - Login tokens limited to close previously devastating ($800 database bill) security hole - Login with REST API now works - Once logged in, authentication of API calls with token works - Creatures can now be fetched using the API
51 lines
1.4 KiB
JavaScript
51 lines
1.4 KiB
JavaScript
import SimpleSchema from 'simpl-schema';
|
|
import Creatures from '/imports/api/creature/creatures/Creatures.js';
|
|
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
|
import CreatureLogs from '/imports/api/creature/log/CreatureLogs.js';
|
|
import { assertViewPermission } from '/imports/api/creature/creatures/creaturePermissions.js';
|
|
import computeCreature from '/imports/api/engine/computeCreature.js';
|
|
import VERSION from '/imports/constants/VERSION.js';
|
|
|
|
let schema = new SimpleSchema({
|
|
creatureId: {
|
|
type: String,
|
|
regEx: SimpleSchema.RegEx.Id,
|
|
},
|
|
});
|
|
|
|
Meteor.publish('singleCharacter', function(creatureId){
|
|
try {
|
|
schema.validate({ creatureId });
|
|
} catch (e){
|
|
this.error(e);
|
|
}
|
|
this.autorun(function (computation){
|
|
let userId = this.userId;
|
|
let creatureCursor
|
|
creatureCursor = Creatures.find({
|
|
_id: creatureId,
|
|
});
|
|
let creature = creatureCursor.fetch()[0];
|
|
try { assertViewPermission(creature, userId) }
|
|
catch(e){ return [] }
|
|
if (creature.computeVersion !== VERSION && computation.firstRun){
|
|
try {
|
|
computeCreature(creatureId)
|
|
}
|
|
catch(e){ console.error(e) }
|
|
}
|
|
return [
|
|
creatureCursor,
|
|
CreatureProperties.find({
|
|
'ancestors.id': creatureId,
|
|
}),
|
|
CreatureLogs.find({
|
|
creatureId,
|
|
}, {
|
|
limit: 20,
|
|
sort: {date: -1},
|
|
}),
|
|
];
|
|
});
|
|
});
|