Skip to content

Commit d4bf522

Browse files
committed
Roll changes forward:
1 parent 965f0e3 commit d4bf522

File tree

1 file changed

+11
-97
lines changed

1 file changed

+11
-97
lines changed

FirebaseAuth/Sources/Swift/MultiFactor/MultiFactor.swift

Lines changed: 11 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -91,33 +91,6 @@ import Foundation
9191
AuthProtoFinalizeMFATOTPEnrollmentRequestInfo(sessionInfo: secret.sessionInfo,
9292
verificationCode: totpAssertion
9393
.oneTimePassword)
94-
<<<<<<< Updated upstream
95-
let request = FinalizeMFAEnrollmentRequest(idToken: self.user?.rawAccessToken(),
96-
displayName: displayName,
97-
totpVerificationInfo: finalizeMFATOTPRequestInfo,
98-
requestConfiguration: user
99-
.requestConfiguration)
100-
Task {
101-
do {
102-
let response = try await auth.backend.call(with: request)
103-
do {
104-
let user = try await auth.completeSignIn(withAccessToken: response.idToken,
105-
accessTokenExpirationDate: nil,
106-
refreshToken: response.refreshToken,
107-
anonymous: false)
108-
try auth.updateCurrentUser(user, byForce: false, savingToDisk: true)
109-
if let completion {
110-
DispatchQueue.main.async {
111-
completion(nil)
112-
}
113-
}
114-
} catch {
115-
DispatchQueue.main.async {
116-
if let completion {
117-
completion(error)
118-
}
119-
}
120-
=======
12194
request = FinalizeMFAEnrollmentRequest(idToken: self.user?.rawAccessToken(),
12295
displayName: displayName,
12396
totpVerificationInfo: finalizeMFATOTPRequestInfo,
@@ -153,81 +126,22 @@ import Foundation
153126

154127
Task {
155128
do {
156-
let response = try await AuthBackend.call(with: request)
157-
do {
158-
let user = try await auth.completeSignIn(withAccessToken: response.idToken,
159-
accessTokenExpirationDate: nil,
160-
refreshToken: response.refreshToken,
161-
anonymous: false)
162-
try auth.updateCurrentUser(user, byForce: false, savingToDisk: true)
163-
if let completion {
164-
DispatchQueue.main.async {
165-
completion(nil)
166-
>>>>>>> Stashed changes
167-
}
168-
}
169-
} catch {
129+
let response = try await auth.backend.call(with: request)
130+
let user = try await auth.completeSignIn(withAccessToken: response.idToken,
131+
accessTokenExpirationDate: nil,
132+
refreshToken: response.refreshToken,
133+
anonymous: false)
134+
try auth.updateCurrentUser(user, byForce: false, savingToDisk: true)
135+
if let completion {
170136
DispatchQueue.main.async {
171-
if let completion {
172-
completion(error)
173-
}
137+
completion(nil)
174138
}
175139
}
176-
<<<<<<< Updated upstream
177-
}
178-
return
179-
} else if assertion.factorID != PhoneMultiFactorInfo.PhoneMultiFactorID {
180-
return
181-
}
182-
let phoneAssertion = assertion as? PhoneMultiFactorAssertion
183-
guard let credential = phoneAssertion?.authCredential else {
184-
fatalError("Internal Error: Missing credential")
185-
}
186-
switch credential.credentialKind {
187-
case .phoneNumber: fatalError("Internal Error: Missing verificationCode")
188-
case let .verification(verificationID, code):
189-
let finalizeMFAPhoneRequestInfo =
190-
AuthProtoFinalizeMFAPhoneRequestInfo(sessionInfo: verificationID, verificationCode: code)
191-
guard let user = user, let auth = user.auth else {
192-
fatalError("Internal Auth error: failed to get user enrolling in MultiFactor")
193-
}
194-
let request = FinalizeMFAEnrollmentRequest(
195-
idToken: self.user?.rawAccessToken(),
196-
displayName: displayName,
197-
phoneVerificationInfo: finalizeMFAPhoneRequestInfo,
198-
requestConfiguration: user.requestConfiguration
199-
)
200-
201-
Task {
202-
do {
203-
let response = try await auth.backend.call(with: request)
204-
do {
205-
let user = try await auth.completeSignIn(withAccessToken: response.idToken,
206-
accessTokenExpirationDate: nil,
207-
refreshToken: response.refreshToken,
208-
anonymous: false)
209-
try auth.updateCurrentUser(user, byForce: false, savingToDisk: true)
210-
if let completion {
211-
DispatchQueue.main.async {
212-
completion(nil)
213-
}
214-
}
215-
} catch {
216-
DispatchQueue.main.async {
217-
if let completion {
218-
completion(error)
219-
}
220-
}
221-
}
222-
} catch {
223-
if let completion {
224-
completion(error)
225-
}
226-
=======
227140
} catch {
228141
if let completion {
229-
completion(error)
230-
>>>>>>> Stashed changes
142+
DispatchQueue.main.async {
143+
completion(error)
144+
}
231145
}
232146
}
233147
}

0 commit comments

Comments
 (0)