Added the setting to swap ability scores and modifiers to the account page
This commit is contained in:
@@ -83,6 +83,15 @@ const userSchema = new SimpleSchema({
|
||||
blackbox: true,
|
||||
optional: true,
|
||||
},
|
||||
preferences: {
|
||||
type: Object,
|
||||
optional: true,
|
||||
defaultValue: {},
|
||||
},
|
||||
'preferences.swapAbilityScoresAndModifiers': {
|
||||
type: Boolean,
|
||||
optional: true,
|
||||
},
|
||||
});
|
||||
|
||||
Meteor.users.attachSchema(userSchema);
|
||||
@@ -192,6 +201,36 @@ Meteor.users.setUsername = new ValidatedMethod({
|
||||
}
|
||||
});
|
||||
|
||||
Meteor.users.setPreference = new ValidatedMethod({
|
||||
name: 'users.setPreference',
|
||||
validate: new SimpleSchema({
|
||||
preference:{
|
||||
type: String,
|
||||
},
|
||||
value: {
|
||||
type: SimpleSchema.oneOf(Boolean),
|
||||
},
|
||||
}).validator(),
|
||||
mixins: [RateLimiterMixin],
|
||||
rateLimit: {
|
||||
numRequests: 5,
|
||||
timeInterval: 5000,
|
||||
},
|
||||
run({preference, value}){
|
||||
if (!this.userId) throw 'You can only set preferences once logged in';
|
||||
let prefPath = `preferences.${preference}`
|
||||
if (value == true){
|
||||
return Meteor.users.update(this.userId, {
|
||||
$set: {[prefPath]: true},
|
||||
});
|
||||
} else {
|
||||
return Meteor.users.update(this.userId, {
|
||||
$unset: {[prefPath]: 1},
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Meteor.users.subscribeToLibrary = new ValidatedMethod({
|
||||
name: 'users.subscribeToLibrary',
|
||||
validate: new SimpleSchema({
|
||||
|
||||
Reference in New Issue
Block a user