mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-20 19:46:32 +08:00
fix(ios): send affine version on sign in (#11058)
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import Foundation
|
||||
|
||||
final class AppConfigManager {
|
||||
struct AppConfig: Decodable {
|
||||
let affineVersion: String
|
||||
}
|
||||
|
||||
static var affineVersion: String? = nil
|
||||
|
||||
static func getAffineVersion() -> String {
|
||||
if affineVersion == nil {
|
||||
let file = Bundle(for: AppConfigManager.self).url(forResource: "capacitor.config", withExtension: "json")!
|
||||
let data = try! Data(contentsOf: file)
|
||||
let config = try! JSONDecoder().decode(AppConfig.self, from: data)
|
||||
affineVersion = config.affineVersion
|
||||
}
|
||||
|
||||
return affineVersion!
|
||||
}
|
||||
}
|
||||
@@ -82,7 +82,7 @@ public class AuthPlugin: CAPPlugin, CAPBridgedPlugin {
|
||||
|
||||
let (data, response) = try await self.fetch(endpoint, method: "POST", action: "/api/auth/sign-in", headers: [
|
||||
"x-captcha-token": verifyToken,
|
||||
"x-captcha-challenge": challenge,
|
||||
"x-captcha-challenge": challenge
|
||||
], body: ["email": email, "password": password])
|
||||
|
||||
if response.statusCode >= 400 {
|
||||
@@ -157,6 +157,7 @@ public class AuthPlugin: CAPPlugin, CAPBridgedPlugin {
|
||||
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
|
||||
request.httpBody = try JSONEncoder().encode(body!)
|
||||
}
|
||||
request.setValue(AppConfigManager.getAffineVersion(), forHTTPHeaderField: "x-affine-version")
|
||||
request.timeoutInterval = 10 // time out 10s
|
||||
|
||||
let (data, response) = try await URLSession.shared.data(for: request);
|
||||
|
||||
Reference in New Issue
Block a user