-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Remove knowledge of AppConfiguration
from WPAccount
Objective-C
#24231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,13 @@ public extension WPAccount { | |
return self.uuid == uuid | ||
} | ||
|
||
// This is here in an extension that belongs to the apps target so we can decouple WPAccount from AppConfiguration. | ||
// Decoupling allows moving the type to WordPressData, see https://github.com/wordpress-mobile/WordPress-iOS/issues/24165. | ||
@objc | ||
static func tokenForUsername(_ username: String) -> String? { | ||
token(forUsername: username, isJetpack: AppConfiguration.isJetpack) | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, @kean I am aware that After all, this is a net zero change. I doesn't remove an |
||
/// Does this `WPAccount` object have any associated blogs? | ||
/// | ||
@objc | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,10 +128,13 @@ - (BOOL)hasAtomicSite { | |
|
||
#pragma mark - Static methods | ||
|
||
+ (NSString *)tokenForUsername:(NSString *)username | ||
+ (NSString *)tokenForUsername:(NSString *)username isJetpack:(BOOL)isJetpack | ||
{ | ||
if (isJetpack) { | ||
[WPAccount migrateAuthKeyForUsername:username]; | ||
} | ||
|
||
NSError *error = nil; | ||
[WPAccount migrateAuthKeyForUsername:username]; | ||
NSString *authToken = [SFHFKeychainUtils getPasswordForUsername:username | ||
andServiceName:[WPAccount authKeychainServiceName] | ||
accessGroup:nil | ||
|
@@ -147,10 +150,8 @@ + (void)migrateAuthKeyForUsername:(NSString *)username | |
{ | ||
static dispatch_once_t onceToken; | ||
dispatch_once(&onceToken, ^{ | ||
if ([AppConfiguration isJetpack]) { | ||
SharedDataIssueSolver *sharedDataIssueSolver = [SharedDataIssueSolver instance]; | ||
[sharedDataIssueSolver migrateAuthKeyFor:username]; | ||
} | ||
SharedDataIssueSolver *sharedDataIssueSolver = [SharedDataIssueSolver instance]; | ||
[sharedDataIssueSolver migrateAuthKeyFor:username]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Notice that moving There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is possible to move the entire There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not easily, because unfortunately it is used to get the There are ~30 usages in the production codebase between [self.coreDataStack performAndSaveUsingBlock:^(NSManagedObjectContext *context) {
WPAccount *account = [context existingObjectWithID:accountObjectID error:nil];
// Even if we find an account via its userID we should still update
// its authtoken, otherwise the Authenticator's authtoken fixer won't
// work.
account.authToken = authToken;
}]; So, I'm not super confident in taking off to remove it just yet. |
||
}); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure whether the
+Lookup
extension is the best where to host this implementation, but it will do for now. "token for username" kind feels like looking up information, no?