From 7dbc1e300da0ed38f1663ae653d289ecb2187118 Mon Sep 17 00:00:00 2001 From: EYHN Date: Wed, 26 Feb 2025 06:32:16 +0000 Subject: [PATCH] fix(ios): fix magic link sign in (#10436) --- .../apps/ios/App/App/Plugins/Auth/AuthPlugin.swift | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/frontend/apps/ios/App/App/Plugins/Auth/AuthPlugin.swift b/packages/frontend/apps/ios/App/App/Plugins/Auth/AuthPlugin.swift index f6ddac39e..01970e2f7 100644 --- a/packages/frontend/apps/ios/App/App/Plugins/Auth/AuthPlugin.swift +++ b/packages/frontend/apps/ios/App/App/Plugins/Auth/AuthPlugin.swift @@ -19,8 +19,8 @@ public class AuthPlugin: CAPPlugin, CAPBridgedPlugin { let token = try call.getStringEnsure("token") let (data, response) = try await self.fetch(endpoint, method: "POST", action: "/api/auth/magic-link", headers: [:], body: ["email": email, "token": token]) - - if response.statusCode != 200 { + + if response.statusCode >= 400 { if let textBody = String(data: data, encoding: .utf8) { call.reject(textBody) } else { @@ -49,7 +49,7 @@ public class AuthPlugin: CAPPlugin, CAPBridgedPlugin { let (data, response) = try await self.fetch(endpoint, method: "POST", action: "/api/oauth/callback", headers: [:], body: ["code": code, "state": state]) - if response.statusCode != 200 { + if response.statusCode >= 400 { if let textBody = String(data: data, encoding: .utf8) { call.reject(textBody) } else { @@ -83,7 +83,7 @@ public class AuthPlugin: CAPPlugin, CAPBridgedPlugin { "x-captcha-challenge": challenge, ], body: ["email": email, "password": password]) - if response.statusCode != 200 { + if response.statusCode >= 400 { if let textBody = String(data: data, encoding: .utf8) { call.reject(textBody) } else { @@ -109,8 +109,8 @@ public class AuthPlugin: CAPPlugin, CAPBridgedPlugin { let endpoint = try call.getStringEnsure("endpoint") let (data, response) = try await self.fetch(endpoint, method: "GET", action: "/api/auth/sign-out", headers: [:], body: nil) - - if response.statusCode != 200 { + + if response.statusCode >= 400 { if let textBody = String(data: data, encoding: .utf8) { call.reject(textBody) } else {