forked from shadowfacts/Tusker
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:
parent
d2c7664073
commit
f88bf552af
|
@ -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,10 +44,16 @@ class OnboardingViewController: UINavigationController {
|
|||
let mastodonController = MastodonController(instanceURL: instanceURL, transient: true)
|
||||
let clientID: String
|
||||
let clientSecret: String
|
||||
do {
|
||||
(clientID, clientSecret) = try await mastodonController.registerApp()
|
||||
} catch {
|
||||
throw Error.registeringApp(error)
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue