Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to logout all previous JWTS #94

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,15 @@ if (refreshJwt != null) {
}
```

When the user wants to revoke previously created sessions, also from other devices:

```dart
final refreshJwt = Descope.sessionManager.session?.refreshJwt;
if (refreshJwt != null) {
Descope.auth.logoutPrevious(refreshJwt);
}
```

You can customize how the `DescopeSessionManager` behaves by using
your own `storage` and `lifecycle` objects. See the documentation
for more details.
Expand Down
4 changes: 4 additions & 0 deletions lib/src/internal/http/descope_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,10 @@ class DescopeClient extends HttpClient {
return post('auth/logout', emptyResponse, headers: authorization(refreshJwt));
}

Future<void> logoutPrevious(String refreshJwt) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No logoutAll?

return post('auth/logoutprevious', emptyResponse, headers: authorization(refreshJwt));
}

// Internal

@override
Expand Down
5 changes: 5 additions & 0 deletions lib/src/internal/routes/auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ class Auth implements DescopeAuth {
Future<void> logout(String refreshJwt) {
return client.logout(refreshJwt);
}

@override
Future<void> logoutPrevious(String refreshJwt) {
return client.logoutPrevious(refreshJwt);
}
}
3 changes: 3 additions & 0 deletions lib/src/sdk/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ abstract class DescopeAuth {

/// Logs out from an active [DescopeSession].
Future<void> logout(String refreshJwt);

/// Revokes all previous created sessions [DescopeSession].
Future<void> logoutPrevious(String refreshJwt);
}

/// Authenticate a user using a flow.
Expand Down