[AltStore] Uses GrandSlam Authentication

Retrieves anisette data from AltServer so we can authenticate with GSA.
This commit is contained in:
Riley Testut
2019-11-18 14:49:17 -08:00
parent 9535595df1
commit 691e08202d
14 changed files with 636 additions and 182 deletions

View File

@@ -12,7 +12,8 @@ import AltSign
class AuthenticationViewController: UIViewController
{
var authenticationHandler: (((ALTAccount, String)?) -> Void)?
var authenticationHandler: ((String, String, @escaping (Result<(ALTAccount, ALTAppleAPISession), Error>) -> Void) -> Void)?
var completionHandler: (((ALTAccount, ALTAppleAPISession, String)?) -> Void)?
private weak var toastView: ToastView?
@@ -96,14 +97,16 @@ private extension AuthenticationViewController
self.signInButton.isIndicatingActivity = true
ALTAppleAPI.shared.authenticate(appleID: emailAddress, password: password) { (account, error) in
do
{
let account = try Result(account, error).get()
self.authenticationHandler?((account, password))
}
catch
self.authenticationHandler?(emailAddress, password) { (result) in
switch result
{
case .failure(ALTAppleAPIError.requiresTwoFactorAuthentication):
// Ignore
DispatchQueue.main.async {
self.signInButton.isIndicatingActivity = false
}
case .failure(let error):
DispatchQueue.main.async {
let toastView = ToastView(text: NSLocalizedString("Failed to Log In", comment: ""), detailText: error.localizedDescription)
toastView.textLabel.textColor = .altPink
@@ -113,6 +116,9 @@ private extension AuthenticationViewController
self.signInButton.isIndicatingActivity = false
}
case .success(let account, let session):
self.completionHandler?((account, session, password))
}
DispatchQueue.main.async {
@@ -123,7 +129,7 @@ private extension AuthenticationViewController
@IBAction func cancel(_ sender: UIBarButtonItem)
{
self.authenticationHandler?(nil)
self.completionHandler?(nil)
}
}