mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 20:38:52 +00:00
fix(ios): fix magic link sign in (#10436)
This commit is contained in:
@@ -19,8 +19,8 @@ public class AuthPlugin: CAPPlugin, CAPBridgedPlugin {
|
|||||||
let token = try call.getStringEnsure("token")
|
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])
|
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) {
|
if let textBody = String(data: data, encoding: .utf8) {
|
||||||
call.reject(textBody)
|
call.reject(textBody)
|
||||||
} else {
|
} 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])
|
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) {
|
if let textBody = String(data: data, encoding: .utf8) {
|
||||||
call.reject(textBody)
|
call.reject(textBody)
|
||||||
} else {
|
} else {
|
||||||
@@ -83,7 +83,7 @@ public class AuthPlugin: CAPPlugin, CAPBridgedPlugin {
|
|||||||
"x-captcha-challenge": challenge,
|
"x-captcha-challenge": challenge,
|
||||||
], body: ["email": email, "password": password])
|
], body: ["email": email, "password": password])
|
||||||
|
|
||||||
if response.statusCode != 200 {
|
if response.statusCode >= 400 {
|
||||||
if let textBody = String(data: data, encoding: .utf8) {
|
if let textBody = String(data: data, encoding: .utf8) {
|
||||||
call.reject(textBody)
|
call.reject(textBody)
|
||||||
} else {
|
} else {
|
||||||
@@ -109,8 +109,8 @@ public class AuthPlugin: CAPPlugin, CAPBridgedPlugin {
|
|||||||
let endpoint = try call.getStringEnsure("endpoint")
|
let endpoint = try call.getStringEnsure("endpoint")
|
||||||
|
|
||||||
let (data, response) = try await self.fetch(endpoint, method: "GET", action: "/api/auth/sign-out", headers: [:], body: nil)
|
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) {
|
if let textBody = String(data: data, encoding: .utf8) {
|
||||||
call.reject(textBody)
|
call.reject(textBody)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user