forked from shadowfacts/Tusker
Add more logging to onboarding VC
This commit is contained in:
parent
c6b230414e
commit
043a708515
|
@ -116,10 +116,13 @@ class OnboardingViewController: UINavigationController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func tryLogin(to instanceURL: URL, updateStatus: (String) -> Void) async throws {
|
private func tryLogin(to instanceURL: URL, updateStatus: (String) -> Void) async throws {
|
||||||
|
logger.debug("Attempting to log in to \(instanceURL, privacy: .public)")
|
||||||
|
|
||||||
let mastodonController = MastodonController(instanceURL: instanceURL, transient: true)
|
let mastodonController = MastodonController(instanceURL: instanceURL, transient: true)
|
||||||
let clientID: String
|
let clientID: String
|
||||||
let clientSecret: String
|
let clientSecret: String
|
||||||
if let clientInfo, clientInfo.url == instanceURL {
|
if let clientInfo, clientInfo.url == instanceURL {
|
||||||
|
logger.debug("Using client info from previous attempt")
|
||||||
clientID = clientInfo.id
|
clientID = clientInfo.id
|
||||||
clientSecret = clientInfo.secret
|
clientSecret = clientInfo.secret
|
||||||
} else {
|
} else {
|
||||||
|
@ -127,21 +130,32 @@ class OnboardingViewController: UINavigationController {
|
||||||
do {
|
do {
|
||||||
(clientID, clientSecret) = try await mastodonController.registerApp()
|
(clientID, clientSecret) = try await mastodonController.registerApp()
|
||||||
self.clientInfo = (instanceURL, clientID, clientSecret)
|
self.clientInfo = (instanceURL, clientID, clientSecret)
|
||||||
|
logger.debug("Obtained client info")
|
||||||
updateStatus("Reticulating Splines")
|
updateStatus("Reticulating Splines")
|
||||||
try await Task.sleep(nanoseconds: 500 * NSEC_PER_MSEC)
|
try await Task.sleep(nanoseconds: 500 * NSEC_PER_MSEC)
|
||||||
} catch {
|
} catch {
|
||||||
|
logger.error("Failed to register app: \(String(describing: error), privacy: .public)")
|
||||||
throw Error.registeringApp(error)
|
throw Error.registeringApp(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateStatus("Logging in")
|
updateStatus("Logging in")
|
||||||
let authCode = try await getAuthorizationCode(instanceURL: instanceURL, clientID: clientID)
|
let authCode: String
|
||||||
|
do {
|
||||||
|
authCode = try await getAuthorizationCode(instanceURL: instanceURL, clientID: clientID)
|
||||||
|
logger.debug("Obtained authorization code")
|
||||||
|
} catch {
|
||||||
|
logger.error("Failed to get auth code: \(String(describing: error), privacy: .public)")
|
||||||
|
throw error
|
||||||
|
}
|
||||||
updateStatus("Authorizing")
|
updateStatus("Authorizing")
|
||||||
let accessToken: String
|
let accessToken: String
|
||||||
do {
|
do {
|
||||||
accessToken = try await retrying("Getting access token") {
|
accessToken = try await retrying("Getting access token") {
|
||||||
try await mastodonController.authorize(authorizationCode: authCode)
|
try await mastodonController.authorize(authorizationCode: authCode)
|
||||||
}
|
}
|
||||||
|
logger.debug("Obtained access token")
|
||||||
} catch {
|
} catch {
|
||||||
|
logger.error("Failed to get access token: \(String(describing: error), privacy: .public)")
|
||||||
throw Error.gettingAccessToken(error)
|
throw Error.gettingAccessToken(error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue