Reuse client ID/secret when trying to sign in to the same account again

Workaround for mastodon.social signins being flaky
This commit is contained in:
Shadowfacts 2023-01-23 17:43:41 -05:00
parent d2c7664073
commit f88bf552af
1 changed files with 12 additions and 4 deletions

View File

@ -23,6 +23,8 @@ class OnboardingViewController: UINavigationController {
var authenticationSession: ASWebAuthenticationSession?
private var clientInfo: (url: URL, id: String, secret: String)?
init() {
super.init(rootViewController: instanceSelector)
}
@ -42,11 +44,17 @@ class OnboardingViewController: UINavigationController {
let mastodonController = MastodonController(instanceURL: instanceURL, transient: true)
let clientID: String
let clientSecret: String
if let clientInfo, clientInfo.url == instanceURL {
clientID = clientInfo.id
clientSecret = clientInfo.secret
} else {
do {
(clientID, clientSecret) = try await mastodonController.registerApp()
self.clientInfo = (instanceURL, clientID, clientSecret)
} catch {
throw Error.registeringApp(error)
}
}
let authCode = try await getAuthorizationCode(instanceURL: instanceURL, clientID: clientID)
let accessToken: String
do {