Skip to content

Commit 0f4f15a

Browse files
committed
chore(auth): Clear browser cookies on sign-out
1 parent 10549de commit 0f4f15a

File tree

8 files changed

+24
-6
lines changed

8 files changed

+24
-6
lines changed

packages/celest_auth/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.0-dev.2
2+
3+
- Clear browser cookies on `signOut`
4+
15
## 0.3.0-dev.1
26

37
- Initial version.

packages/celest_auth/lib/src/auth.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ abstract interface class Auth {
2020
Stream<AuthState> get authStateChanges;
2121

2222
/// Signs out the current user, if any.
23-
void signOut();
23+
Future<void> signOut();
2424
}

packages/celest_auth/lib/src/auth_impl.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,14 @@ final class AuthImpl implements Auth {
8282
}
8383

8484
@override
85-
void signOut() {
85+
Future<void> signOut() async {
8686
localStorage.delete('userId');
8787
secureStorage.delete('cork');
88-
_authStateController.add(const Unauthenticated());
88+
try {
89+
await protocol.signOut();
90+
} finally {
91+
_authStateController.add(const Unauthenticated());
92+
}
8993
}
9094

9195
final CelestBase celest;

packages/celest_auth/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: celest_auth
22
description: The Auth runtime and client library for Celest, the Flutter cloud platform.
3-
version: 0.3.0-dev.1
3+
version: 0.3.0-dev.2
44
homepage: https://celest.dev
55
repository: https://github.com/celest-dev/celest/tree/main/packages/celest_auth
66

@@ -12,7 +12,7 @@ dependencies:
1212
built_collection: ^5.1.1
1313
built_value: ^8.9.1
1414
cedar: ^0.1.0
15-
celest_core: ^0.3.0-dev.1
15+
celest_core: ^0.3.0-dev.2
1616
chunked_stream: ^1.4.2
1717
corks_cedar: ^0.1.0
1818
ffi: ^2.1.2

packages/celest_core/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.0-dev.2
2+
3+
- Add `signOut` method to `AuthProtocol` for clearing browser cookies
4+
15
## 0.3.0-dev.1
26

37
- Adds `SecureStorage` interface for storage of sensitive data in the platform keychain

packages/celest_core/lib/src/auth/auth_client.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ final class AuthClient with BaseProtocol implements AuthProtocol {
1616
return User.fromJson(response);
1717
}
1818

19+
@override
20+
Future<void> signOut() async {
21+
await postJson('/_auth/sign-out', {});
22+
}
23+
1924
@override
2025
late final EmailClient email = EmailClient(celest);
2126
}

packages/celest_core/lib/src/auth/auth_protocol.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ abstract interface class AuthProtocol {
55
EmailProtocol get email;
66

77
Future<User> userInfo();
8+
Future<void> signOut();
89
}
910

1011
abstract interface class EmailProtocol {

packages/celest_core/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: celest_core
22
description: Celest types and utilities shared between the client and the cloud.
3-
version: 0.3.0-dev.1
3+
version: 0.3.0-dev.2
44
homepage: https://celest.dev
55
repository: https://github.com/celest-dev/celest/tree/main/packages/celest_core
66

0 commit comments

Comments
 (0)