mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
Fixes authenticating with old email address after changing Apple ID’s primary email
This commit is contained in:
@@ -49,6 +49,7 @@ class AuthenticationOperation: ResultOperation<(ALTTeam, ALTCertificate, ALTAppl
|
|||||||
|
|
||||||
private lazy var storyboard = UIStoryboard(name: "Authentication", bundle: nil)
|
private lazy var storyboard = UIStoryboard(name: "Authentication", bundle: nil)
|
||||||
|
|
||||||
|
private var appleIDEmailAddress: String?
|
||||||
private var appleIDPassword: String?
|
private var appleIDPassword: String?
|
||||||
private var shouldShowInstructions = false
|
private var shouldShowInstructions = false
|
||||||
|
|
||||||
@@ -174,6 +175,13 @@ class AuthenticationOperation: ResultOperation<(ALTTeam, ALTCertificate, ALTAppl
|
|||||||
}
|
}
|
||||||
|
|
||||||
account.update(account: altTeam.account)
|
account.update(account: altTeam.account)
|
||||||
|
|
||||||
|
if let providedEmailAddress = self.appleIDEmailAddress
|
||||||
|
{
|
||||||
|
// Save the user's provided email address instead of the one associated with their account (which may be outdated).
|
||||||
|
account.appleID = providedEmailAddress
|
||||||
|
}
|
||||||
|
|
||||||
team.update(team: altTeam)
|
team.update(team: altTeam)
|
||||||
|
|
||||||
try context.save()
|
try context.save()
|
||||||
@@ -242,7 +250,7 @@ class AuthenticationOperation: ResultOperation<(ALTTeam, ALTCertificate, ALTAppl
|
|||||||
try context.save()
|
try context.save()
|
||||||
|
|
||||||
// Update keychain
|
// Update keychain
|
||||||
Keychain.shared.appleIDEmailAddress = altTeam.account.appleID
|
Keychain.shared.appleIDEmailAddress = self.appleIDEmailAddress ?? altTeam.account.appleID // Prefer the user's provided email address over the one associated with their account (which may be outdated).
|
||||||
Keychain.shared.appleIDPassword = self.appleIDPassword
|
Keychain.shared.appleIDPassword = self.appleIDPassword
|
||||||
|
|
||||||
Keychain.shared.signingCertificate = altCertificate.p12Data()
|
Keychain.shared.signingCertificate = altCertificate.p12Data()
|
||||||
@@ -359,6 +367,8 @@ private extension AuthenticationOperation
|
|||||||
|
|
||||||
func authenticate(appleID: String, password: String, completionHandler: @escaping (Result<(ALTAccount, ALTAppleAPISession), Swift.Error>) -> Void)
|
func authenticate(appleID: String, password: String, completionHandler: @escaping (Result<(ALTAccount, ALTAppleAPISession), Swift.Error>) -> Void)
|
||||||
{
|
{
|
||||||
|
self.appleIDEmailAddress = appleID
|
||||||
|
|
||||||
let fetchAnisetteDataOperation = FetchAnisetteDataOperation(context: self.context)
|
let fetchAnisetteDataOperation = FetchAnisetteDataOperation(context: self.context)
|
||||||
fetchAnisetteDataOperation.resultHandler = { (result) in
|
fetchAnisetteDataOperation.resultHandler = { (result) in
|
||||||
switch result
|
switch result
|
||||||
|
|||||||
Reference in New Issue
Block a user