signOut method
Logs out the current user.
If all
is true, all of the user's devices will be logged out.
Returns an AuthResponse
with its fields unset.
Throws an NhostException
if sign out fails.
Implementation
@override
Future<AuthResponse> signOut({
bool all = false,
}) async {
log.finer('Attempting sign out');
final refreshToken = await _authStore.getString(
refreshTokenClientStorageKey,
);
try {
await _apiClient.post(
'/signout',
jsonBody: {
'refreshToken': refreshToken,
'all': all,
},
);
log.finer('Sign out successful');
} catch (e, st) {
log.finer('Sign out failed', e, st);
// noop
// TODO(shyndman): This probably shouldn't be a noop. If a signout fails,
// particularly in the ?all=true case, the user should know about it
}
await clearSession();
return AuthResponse(session: null);
}