Skip to content

Commit 8cf7db7

Browse files
mtrezzaTomWFox
andcommitted
Add afterLogout trigger docs (#684)
* added docs for afterLogout trigger * corrected server version for massive release * change note to 3.10.0 Co-authored-by: Tom Fox <[email protected]>
1 parent cc489df commit 8cf7db7

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

_includes/cloudcode/cloud-code.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,31 @@ Parse.Cloud.beforeLogin(async request => {
459459
- On sign up
460460
- If the login credentials are incorrect
461461
462+
# afterLogout Triggers
463+
464+
*Available only on parse-server cloud code starting 3.10.0*
465+
466+
Sometimes you may want to run actions after a user logs out. For example, the `afterLogout` trigger can be used for clean-up actions after a user logs out. The triggers contains the session object that has been deleted on logout. From this session object you can determine the user who logged out to perform user-specific tasks.
467+
468+
```javascript
469+
Parse.Cloud.afterLogout(async request => {
470+
const { object: session } = request;
471+
const user = session.get('user');
472+
user.set('isOnline', false);
473+
user.save(null,{useMasterKey:true});
474+
});
475+
```
476+
477+
## Some considerations to be aware of
478+
- Like with `afterDelete` triggers, the `_Session` object that is contained in the request has already been deleted.
479+
480+
### The trigger will run...
481+
- when the user logs out and a `_Session` object was deleted
482+
483+
### The trigger won't run...
484+
- if a user logs out and no `_Session` object was found to delete
485+
- if a `_Session` object is deleted without the user logging out by calling the logout method of an SDK
486+
462487
# LiveQuery Triggers
463488
464489
*Available only on parse-server cloud code starting 2.6.2*

0 commit comments

Comments
 (0)