How to use the simpl-schema.SimpleSchema.denyUntrusted function in simpl-schema

To help you get started, we’ve selected a few simpl-schema examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github copleykj / socialize-base-model / security.js View on Github external
import { SimpleSchema } from 'simpl-schema';
import MessageBox from 'message-box';


MessageBox.defaults({
    messages: {
        en: {
            Untrusted: "Inserts/Updates from untrusted code not supported"
        },
    },
});

SimpleSchema.denyUntrusted = function() {
    if(this.isSet){
        var autoValue = this.definition.autoValue && this.definition.autoValue.call(this);
        var defaultValue = this.definition.defaultValue;

        if(this.value != defaultValue && this.value != autoValue && !this.isFromTrustedCode){
            return "Untrusted";
        }
    }
};