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
Branches
Tags
2 merge requests!102Release 1.0.0,!18Update Bindings
......@@ -2,33 +2,46 @@ import Bindings
import XCTestDynamicOverlay
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(
ephemeral: Bool,
cmixId: Int,
authCallbacks: AuthCallbacks? = nil,
identity: Data,
e2eParamsJSON: Data
) throws -> E2E {
try run(cmixId, authCallbacks, identity, e2eParamsJSON)
try run(ephemeral, cmixId, authCallbacks, identity, e2eParamsJSON)
}
}
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?
let bindingsE2E = BindingsLogin(
let bindingsE2E: BindingsE2e?
if ephemeral {
bindingsE2E = BindingsLogin(
cmixId,
authCallbacks?.makeBindingsAuthCallbacks(),
identity,
e2eParamsJSON,
&error
)
} else {
bindingsE2E = BindingsLoginEphemeral(
cmixId,
authCallbacks?.makeBindingsAuthCallbacks(),
identity,
e2eParamsJSON,
&error
)
}
if let error = error {
throw error
}
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)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment