MCPcopy Index your code
hub / github.com/parse-community/parse-server / validateClassNameForTriggers

Function validateClassNameForTriggers

src/triggers.js:66–89  ·  view source on GitHub ↗
(className, type)

Source from the content-addressed store, hash-verified

64}
65
66function validateClassNameForTriggers(className, type) {
67 if (type == Types.beforeSave && className === '_PushStatus') {
68 // _PushStatus uses undocumented nested key increment ops
69 // allowing beforeSave would mess up the objects big time
70 // TODO: Allow proper documented way of using nested increment ops
71 throw 'Only afterSave is allowed on _PushStatus';
72 }
73 if ((type === Types.beforeLogin || type === Types.afterLogin || type === Types.beforePasswordResetRequest) && className !== '_User') {
74 // TODO: check if upstream code will handle `Error` instance rather
75 // than this anti-pattern of throwing strings
76 throw 'Only the _User class is allowed for the beforeLogin, afterLogin, and beforePasswordResetRequest triggers';
77 }
78 if (type === Types.afterLogout && className !== '_Session') {
79 // TODO: check if upstream code will handle `Error` instance rather
80 // than this anti-pattern of throwing strings
81 throw 'Only the _Session class is allowed for the afterLogout trigger.';
82 }
83 if (className === '_Session' && type !== Types.afterLogout) {
84 // TODO: check if upstream code will handle `Error` instance rather
85 // than this anti-pattern of throwing strings
86 throw 'Only the afterLogout trigger is allowed for the _Session class.';
87 }
88 return className;
89}
90
91const _triggerStore = Object.create(null);
92

Callers 1

addTriggerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected