Skip to content
Snippets Groups Projects
Commit 3ace5182 authored by Dariusz Rybicki's avatar Dariusz Rybicki
Browse files

Support ephemeral login in Login functor

parent 63bb6b2a
No related branches found
No related tags found
2 merge requests!102Release 1.0.0,!18Update Bindings
...@@ -2,33 +2,46 @@ import Bindings ...@@ -2,33 +2,46 @@ import Bindings
import XCTestDynamicOverlay import XCTestDynamicOverlay
public struct Login { public struct Login {
public var run: (Int, AuthCallbacks?, Data, Data) throws -> E2E public var run: (Bool, Int, AuthCallbacks?, Data, Data) throws -> E2E
public func callAsFunction( public func callAsFunction(
ephemeral: Bool,
cmixId: Int, cmixId: Int,
authCallbacks: AuthCallbacks? = nil, authCallbacks: AuthCallbacks? = nil,
identity: Data, identity: Data,
e2eParamsJSON: Data e2eParamsJSON: Data
) throws -> E2E { ) throws -> E2E {
try run(cmixId, authCallbacks, identity, e2eParamsJSON) try run(ephemeral, cmixId, authCallbacks, identity, e2eParamsJSON)
} }
} }
extension Login { extension Login {
public static let live = Login { cmixId, authCallbacks, identity, e2eParamsJSON in public static let live = Login { ephemeral, cmixId, authCallbacks, identity, e2eParamsJSON in
var error: NSError? var error: NSError?
let bindingsE2E = BindingsLogin( let bindingsE2E: BindingsE2e?
cmixId, if ephemeral {
authCallbacks?.makeBindingsAuthCallbacks(), bindingsE2E = BindingsLogin(
identity, cmixId,
e2eParamsJSON, authCallbacks?.makeBindingsAuthCallbacks(),
&error identity,
) e2eParamsJSON,
&error
)
} else {
bindingsE2E = BindingsLoginEphemeral(
cmixId,
authCallbacks?.makeBindingsAuthCallbacks(),
identity,
e2eParamsJSON,
&error
)
}
if let error = error { if let error = error {
throw error throw error
} }
guard let bindingsE2E = bindingsE2E else { guard let bindingsE2E = bindingsE2E else {
fatalError("BindingsLogin returned `nil` without providing error") let functionName = "BindingsLogin\(ephemeral ? "Ephemeral" : "")"
fatalError("\(functionName) returned `nil` without providing error")
} }
return .live(bindingsE2E) return .live(bindingsE2E)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment