| 64 | } |
| 65 | |
| 66 | function 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 | |
| 91 | const _triggerStore = Object.create(null); |
| 92 | |