Skip to content

Commit 2af4c74

Browse files
author
Bernabe Gonzalez
committed
Add function to validate the session
1 parent 4eb7d32 commit 2af4c74

File tree

13 files changed

+10971
-1849
lines changed

13 files changed

+10971
-1849
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,17 @@ Once the promise is resolved or rejected the flag `checked` in the redux store w
6666
Options:
6767
- refreshOnCheckAuth(**default**: false): Refresh Redux store in the `checkAuth` function
6868
- redirectPath(**default**: `"login"`): Path used when a session is rejected or doesn't exist
69-
- driver: Force to use a particular driver, should be: 'INDEXEDDB', 'WEBSQL', 'LOCALSTORAGE' or 'COOKIES'
69+
- driver: Force to use a particular driver, could be: 'INDEXEDDB', 'WEBSQL', 'LOCALSTORAGE' or 'COOKIES'
70+
- validateSession: Function to validate the saved session, it should return a BOOLEAN. If it returns `false` the session will be destroyed
7071

7172
Example:
7273
```javascript
73-
const options = { refreshOnCheckAuth: true, redirectPath: '/home', driver: 'COOKIES' };
74+
const validateSession = (session) => {
75+
// check if your session is still valid
76+
return true;
77+
}
78+
const options = { refreshOnCheckAuth: true, redirectPath: '/home', driver: 'COOKIES', validateSession };
79+
7480
sessionService.initSessionService(store, options)
7581
.then(() => console.log('Redux React Session is ready and a session was refreshed from your storage'))
7682
.catch(() => console.log('Redux React Session is ready and there is no session in your storage'));

0 commit comments

Comments
 (0)