Skip to content

Commit 1bb7ba9

Browse files
committed
fix issue with signOut
1 parent 5a2340b commit 1bb7ba9

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

Sources/Auth/AuthClient.swift

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -914,20 +914,22 @@ public actor AuthClient {
914914
eventEmitter.emit(.signedOut, session: nil)
915915
}
916916

917-
do {
918-
_ = try await self.api.execute(
919-
self.configuration.url.appendingPathComponent("logout"),
920-
method: .post,
921-
headers: [.authorization(bearerToken: accessToken)],
922-
query: ["scope": scope.rawValue]
923-
)
924-
.serializingData()
925-
.value
926-
} catch let AuthError.api(_, _, _, response)
927-
where [404, 403, 401].contains(response.statusCode)
928-
{
917+
let response = try await self.api.execute(
918+
self.configuration.url.appendingPathComponent("logout"),
919+
method: .post,
920+
headers: [.authorization(bearerToken: accessToken)],
921+
query: ["scope": scope.rawValue]
922+
)
923+
.serializingData()
924+
.response
925+
926+
if let response = response.response, [404, 403, 401].contains(response.statusCode) {
929927
// ignore 404s since user might not exist anymore
930928
// ignore 401s, and 403s since an invalid or expired JWT should sign out the current session.
929+
} else if let error = response.error {
930+
throw error
931+
} else {
932+
// success, no-op
931933
}
932934
}
933935

0 commit comments

Comments
 (0)