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?
|
var authenticationSession: ASWebAuthenticationSession?
|
||||||
|
|
||||||
|
private var clientInfo: (url: URL, id: String, secret: String)?
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
super.init(rootViewController: instanceSelector)
|
super.init(rootViewController: instanceSelector)
|
||||||
}
|
}
|
||||||
|
@ -42,10 +44,16 @@ class OnboardingViewController: UINavigationController {
|
||||||
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
|
||||||
do {
|
if let clientInfo, clientInfo.url == instanceURL {
|
||||||
(clientID, clientSecret) = try await mastodonController.registerApp()
|
clientID = clientInfo.id
|
||||||
} catch {
|
clientSecret = clientInfo.secret
|
||||||
throw Error.registeringApp(error)
|
} 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 authCode = try await getAuthorizationCode(instanceURL: instanceURL, clientID: clientID)
|
||||||
let accessToken: String
|
let accessToken: String
|
||||||
|
|
Loading…
Reference in New Issue