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

chore(auth): Clear browser cookies on sign-out #78

Merged
merged 1 commit into from
Mar 9, 2024
Merged
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
4 changes: 4 additions & 0 deletions packages/celest_auth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.0-dev.2

- Clear browser cookies on `signOut`

## 0.3.0-dev.1

- Initial version.
2 changes: 1 addition & 1 deletion packages/celest_auth/lib/src/auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ abstract interface class Auth {
Stream<AuthState> get authStateChanges;

/// Signs out the current user, if any.
void signOut();
Future<void> signOut();
}
8 changes: 6 additions & 2 deletions packages/celest_auth/lib/src/auth_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,14 @@ final class AuthImpl implements Auth {
}

@override
void signOut() {
Future<void> signOut() async {
localStorage.delete('userId');
secureStorage.delete('cork');
_authStateController.add(const Unauthenticated());
try {
await protocol.signOut();
} finally {
_authStateController.add(const Unauthenticated());
}
}

final CelestBase celest;
Expand Down
4 changes: 2 additions & 2 deletions packages/celest_auth/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: celest_auth
description: The Auth runtime and client library for Celest, the Flutter cloud platform.
version: 0.3.0-dev.1
version: 0.3.0-dev.2
homepage: https://celest.dev
repository: https://github.com/celest-dev/celest/tree/main/packages/celest_auth

Expand All @@ -12,7 +12,7 @@ dependencies:
built_collection: ^5.1.1
built_value: ^8.9.1
cedar: ^0.1.0
celest_core: ^0.3.0-dev.1
celest_core: ^0.3.0-dev.2
chunked_stream: ^1.4.2
corks_cedar: ^0.1.0
ffi: ^2.1.2
Expand Down
4 changes: 4 additions & 0 deletions packages/celest_core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.0-dev.2

- Add `signOut` method to `AuthProtocol` for clearing browser cookies

## 0.3.0-dev.1

- Adds `SecureStorage` interface for storage of sensitive data in the platform keychain
Expand Down
5 changes: 5 additions & 0 deletions packages/celest_core/lib/src/auth/auth_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ final class AuthClient with BaseProtocol implements AuthProtocol {
return User.fromJson(response);
}

@override
Future<void> signOut() async {
await postJson('/_auth/sign-out', {});
}

@override
late final EmailClient email = EmailClient(celest);
}
Expand Down
1 change: 1 addition & 0 deletions packages/celest_core/lib/src/auth/auth_protocol.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ abstract interface class AuthProtocol {
EmailProtocol get email;

Future<User> userInfo();
Future<void> signOut();
}

abstract interface class EmailProtocol {
Expand Down
2 changes: 1 addition & 1 deletion packages/celest_core/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: celest_core
description: Celest types and utilities shared between the client and the cloud.
version: 0.3.0-dev.1
version: 0.3.0-dev.2
homepage: https://celest.dev
repository: https://github.com/celest-dev/celest/tree/main/packages/celest_core

Expand Down
Loading