feat(auth): add staff-specific sign-out endpoint and enhance session management

This commit is contained in:
Achintha Isuru
2026-03-17 10:21:57 -04:00
parent bad2a3d976
commit b289ed3b02
5 changed files with 72 additions and 10 deletions

View File

@@ -210,6 +210,13 @@ class AuthRepositoryImpl implements AuthRepositoryInterface {
}
}
// Step 5: Populate StaffSessionStore from the V2 auth envelope.
if (staffData != null) {
final domain.StaffSession staffSession =
domain.StaffSession.fromJson(data);
StaffSessionStore.instance.setSession(staffSession);
}
// Build the domain user from the V2 response.
final domain.User domainUser = domain.User(
id: userData?['id'] as String? ?? firebaseUser.uid,
@@ -226,11 +233,12 @@ class AuthRepositoryImpl implements AuthRepositoryInterface {
@override
Future<void> signOut() async {
try {
await _apiService.post(V2ApiEndpoints.signOut);
await _apiService.post(V2ApiEndpoints.staffSignOut);
} catch (_) {
// Sign-out should not fail even if the API call fails.
// The local sign-out below will clear the session regardless.
}
await _auth.signOut();
StaffSessionStore.instance.clear();
}
}

View File

@@ -105,6 +105,8 @@ class _PhoneVerificationPageState extends State<PhoneVerificationPage> {
if (state.status == AuthStatus.authenticated) {
if (state.mode == AuthMode.signup) {
Modular.to.toProfileSetup();
} else {
Modular.to.toStaffHome();
}
} else if (state.status == AuthStatus.error &&
state.mode == AuthMode.signup) {
@@ -155,7 +157,7 @@ class _PhoneVerificationPageState extends State<PhoneVerificationPage> {
BlocProvider.of<AuthBloc>(
context,
).add(AuthResetRequested(mode: widget.mode));
Modular.to.popSafe();;
Modular.to.popSafe();
},
),
body: SafeArea(