🏪 Restore signIn call for 10.12 and below

This commit is contained in:
Ben Chatelain 2018-08-10 21:04:21 -06:00
parent 2c06966c33
commit 2518736c4c
2 changed files with 28 additions and 22 deletions

View file

@ -19,23 +19,23 @@ extension ISStoreAccount {
guard let username = username, let password = password else { fatalError() }
var account: ISStoreAccount? = nil
let error: MASError? = nil
var error: MASError? = nil
let accountService: ISAccountService = ISServiceProxy.genericShared().accountService
let client = ISStoreClient(storeClientType: 0)
accountService.setStoreClient(client)
// let context = ISAuthenticationContext(accountID: 0)!
// context.appleIDOverride = username
//
// if systemDialog {
// context.appleIDOverride = username
// } else {
// context.demoMode = true
// context.demoAccountName = username
// context.demoAccountPassword = password
// context.demoAutologinMode = true
// }
let context = ISAuthenticationContext(accountID: 0)
context.appleIDOverride = username
if systemDialog {
context.appleIDOverride = username
} else {
context.demoMode = true
context.demoAccountName = username
context.demoAccountPassword = password
context.demoAutologinMode = true
}
let group = DispatchGroup()
group.enter()
@ -64,15 +64,16 @@ extension ISStoreAccount {
}
group.leave()
}
// accountService.signIn(with: context) { success, _account, _error in
// if success {
// account = _account
// } else {
// error = .signInFailed(error: _error as NSError?)
// }
// group.leave()
// }
// Only works on macOS Sierra and below
accountService.signIn(with: context) { success, _account, _error in
if success {
account = _account
} else {
error = .signInFailed(error: _error as NSError?)
}
group.leave()
}
if systemDialog {
group.wait()

View file

@ -44,6 +44,11 @@ NS_ASSUME_NONNULL_BEGIN
// - (void)parseCreditStringForProtocol:(NSDictionary *)arg1;
- (void)signOut;
// This method was removed in macOS High Sierra
// https://github.com/mas-cli/mas/issues/107
- (void)signInWithContext:(ISAuthenticationContext * __nonnull)arg1 replyBlock:(void (^ __nonnull)(BOOL, ISStoreAccount * __nullable, NSError * __nullable))arg2 NS_DEPRECATED_MAC(10_9, 10.12);
- (void)addAccount:(ISStoreAccount *)arg1;
- (void)addAccountWithAuthenticationResponse:(ISAuthenticationResponse *)arg1 makePrimary:(BOOL)arg2 replyBlock:(void (^)(ISStoreAccount *))arg3;
- (void)accountWithAppleID:(NSString *)arg1 replyBlock:(void (^)(ISStoreAccount *))arg2;