mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-19 19:53:25 +01:00
[AltStore] Fixes presenting auth alert on background thread
This commit is contained in:
@@ -168,37 +168,39 @@ private extension AppManager
|
|||||||
|
|
||||||
func authenticate(presentingViewController: UIViewController, completionHandler: @escaping (Result<ALTTeam, Error>) -> Void)
|
func authenticate(presentingViewController: UIViewController, completionHandler: @escaping (Result<ALTTeam, Error>) -> Void)
|
||||||
{
|
{
|
||||||
let alertController = UIAlertController(title: "Enter Apple ID + Password", message: "", preferredStyle: .alert)
|
DispatchQueue.main.async {
|
||||||
alertController.addTextField { (textField) in
|
let alertController = UIAlertController(title: "Enter Apple ID + Password", message: "", preferredStyle: .alert)
|
||||||
textField.placeholder = "Apple ID"
|
alertController.addTextField { (textField) in
|
||||||
textField.textContentType = .emailAddress
|
textField.placeholder = "Apple ID"
|
||||||
}
|
textField.textContentType = .emailAddress
|
||||||
alertController.addTextField { (textField) in
|
|
||||||
textField.placeholder = "Password"
|
|
||||||
textField.textContentType = .password
|
|
||||||
}
|
|
||||||
alertController.addAction(.cancel)
|
|
||||||
alertController.addAction(UIAlertAction(title: "Sign In", style: .default) { [unowned alertController] (action) in
|
|
||||||
guard
|
|
||||||
let emailAddress = alertController.textFields![0].text,
|
|
||||||
let password = alertController.textFields![1].text,
|
|
||||||
!emailAddress.isEmpty, !password.isEmpty
|
|
||||||
else { return completionHandler(.failure(ALTAppleAPIError(.incorrectCredentials))) }
|
|
||||||
|
|
||||||
ALTAppleAPI.shared.authenticate(appleID: emailAddress, password: password) { (account, error) in
|
|
||||||
do
|
|
||||||
{
|
|
||||||
let account = try Result(account, error).get()
|
|
||||||
self.fetchTeam(for: account, presentingViewController: presentingViewController, completionHandler: completionHandler)
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
completionHandler(.failure(error))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
alertController.addTextField { (textField) in
|
||||||
|
textField.placeholder = "Password"
|
||||||
presentingViewController.present(alertController, animated: true, completion: nil)
|
textField.textContentType = .password
|
||||||
|
}
|
||||||
|
alertController.addAction(.cancel)
|
||||||
|
alertController.addAction(UIAlertAction(title: "Sign In", style: .default) { [unowned alertController] (action) in
|
||||||
|
guard
|
||||||
|
let emailAddress = alertController.textFields![0].text,
|
||||||
|
let password = alertController.textFields![1].text,
|
||||||
|
!emailAddress.isEmpty, !password.isEmpty
|
||||||
|
else { return completionHandler(.failure(ALTAppleAPIError(.incorrectCredentials))) }
|
||||||
|
|
||||||
|
ALTAppleAPI.shared.authenticate(appleID: emailAddress, password: password) { (account, error) in
|
||||||
|
do
|
||||||
|
{
|
||||||
|
let account = try Result(account, error).get()
|
||||||
|
self.fetchTeam(for: account, presentingViewController: presentingViewController, completionHandler: completionHandler)
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
completionHandler(.failure(error))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
presentingViewController.present(alertController, animated: true, completion: nil)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func fetchSigningResources(for app: App, team: ALTTeam, presentingViewController: UIViewController, completionHandler: @escaping (Result<(ALTCertificate, ALTProvisioningProfile), Error>) -> Void)
|
func fetchSigningResources(for app: App, team: ALTTeam, presentingViewController: UIViewController, completionHandler: @escaping (Result<(ALTCertificate, ALTProvisioningProfile), Error>) -> Void)
|
||||||
|
|||||||
Reference in New Issue
Block a user