Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
72f862f
WPWebViewController: Minor cleanup
jleandroperez Feb 19, 2015
b0308d6
WPWebViewController: Nukes dead code
jleandroperez Feb 19, 2015
da5167a
WPWebViewController: Updates log calls
jleandroperez Feb 19, 2015
d498157
WPWebViewController: Implements authToken mechanism
jleandroperez Feb 19, 2015
f3b3ae7
WPWebViewController: Never send a password if the token is present
jleandroperez Feb 19, 2015
77bc8b8
Stops storing passwords for WordPress.com accounts
jleandroperez Feb 19, 2015
6c71ed8
Fixes Unit Tests
jleandroperez Feb 19, 2015
d23e5bd
EditSiteViewController: Cleanup
jleandroperez Feb 19, 2015
2a25726
Blog: Adds authToken helper
jleandroperez Feb 19, 2015
a955c0c
WPWebViewController: Minor Update
jleandroperez Feb 19, 2015
21c5305
Renames UIDevice category
jleandroperez Feb 20, 2015
da2e083
Renames UIDevice category. Part II
jleandroperez Feb 20, 2015
a20ca44
WordPressComApi: instancetype instead of id
jleandroperez Feb 20, 2015
f995309
Adds WordPress UserAgent Helper
jleandroperez Feb 20, 2015
6baeb70
Wires UIDevice UserAgent helper
jleandroperez Feb 20, 2015
7605d83
Implements NSURLRequest Helper
jleandroperez Feb 20, 2015
0261834
Adds missing imports
jleandroperez Feb 20, 2015
0d0a317
JetpackSettingsViewController: Constants should be static
jleandroperez Feb 20, 2015
bfe9e59
Wires WPWebViewController's bearer token
jleandroperez Feb 20, 2015
f7c66e1
EditSiteViewController: Fixes error check logic
jleandroperez Feb 20, 2015
7d1355b
JetpackSettings doesn't really require Bearer Token
jleandroperez Feb 20, 2015
35ff96e
Merge remote-tracking branch 'origin/develop' into issues/1220-dont-s…
jleandroperez Feb 20, 2015
77de8e7
StatsWebViewController: Nukes unneeded header
jleandroperez Feb 20, 2015
47d5f2d
WPAccount: No more password for WordPress.com accounts
jleandroperez Feb 23, 2015
9bd6af9
Setup SingleSignOn on account change
jleandroperez Feb 23, 2015
4972b5f
Single Sign On now supports authToken
jleandroperez Feb 23, 2015
818c2b5
Updates WordPressApi Dependency
jleandroperez Feb 23, 2015
2ce63aa
Merge remote-tracking branch 'origin/develop' into issues/1220-dont-s…
jleandroperez Feb 23, 2015
129e59b
Restores User-Agent AppDelegate mechanism
jleandroperez Feb 24, 2015
d895031
Wires AppDelegate User Agent getter
jleandroperez Feb 24, 2015
56f5002
NSURLRequest+Helpers: Prevents copying the request
jleandroperez Feb 24, 2015
bd57cf2
NSURLRequest+Helpers: Documents helpers
jleandroperez Feb 24, 2015
d78f295
WPURLRequest is the new old NSURLRequest+Helpers
jleandroperez Feb 24, 2015
bfbdee4
WPAccount: nil password for dotcom accounts
jleandroperez Feb 24, 2015
fe37919
Removes WordPress.com passwords at launch. If needed
jleandroperez Feb 25, 2015
93bd533
Updates WordPressApi Dependency
jleandroperez Feb 25, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pod 'UIDeviceIdentifier', '~> 0.1'
pod 'SVProgressHUD', :git => 'https://github.com/TransitApp/SVProgressHUD.git', :commit => '2ac46ae2f2dd37db153ce1daea73b1273ac2bba3'
pod 'AMPopTip', '~> 0.7'
pod 'wpxmlrpc', '~> 0.7'
pod 'WordPressApi', '~> 0.3.1'
pod 'WordPressApi', '~> 0.3.4'
pod 'NSObject-SafeExpectations', '0.0.2'
pod 'Mixpanel', '2.5.4'
pod 'CocoaLumberjack', '~>1.9'
Expand Down
20 changes: 10 additions & 10 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PODS:
- 1PasswordExtension (1.1)
- 1PasswordExtension (1.1.2)
- AFNetworking (2.5.1):
- AFNetworking/NSURLConnection (= 2.5.1)
- AFNetworking/NSURLSession (= 2.5.1)
Expand Down Expand Up @@ -35,11 +35,11 @@ PODS:
- DTFoundation/DTAnimatedGIF (~> 1.7.1)
- DTFoundation/DTHTMLParser (~> 1.7.1)
- DTFoundation/UIKit (~> 1.7.1)
- DTFoundation/Core (1.7.4)
- DTFoundation/DTAnimatedGIF (1.7.4)
- DTFoundation/DTHTMLParser (1.7.4):
- DTFoundation/Core (1.7.5)
- DTFoundation/DTAnimatedGIF (1.7.5)
- DTFoundation/DTHTMLParser (1.7.5):
- DTFoundation/Core
- DTFoundation/UIKit (1.7.4):
- DTFoundation/UIKit (1.7.5):
- DTFoundation/Core
- EmailChecker (0.1)
- Google-Diff-Match-Patch (0.0.1)
Expand Down Expand Up @@ -110,7 +110,7 @@ PODS:
- WordPress-iOS-Shared (0.2.2):
- AFNetworking (~> 2.5.1)
- CocoaLumberjack (~> 1.9)
- WordPressApi (0.3.1):
- WordPressApi (0.3.4):
- AFNetworking (~> 2.5.1)
- wpxmlrpc (~> 0.7)
- WordPressCom-Analytics-iOS (0.0.26)
Expand Down Expand Up @@ -152,7 +152,7 @@ DEPENDENCIES:
- WordPress-AppbotX (from `https://github.com/wordpress-mobile/appbotx.git`, commit `303b8068530389ea87afde38b77466d685fe3210`)
- WordPress-iOS-Editor (from `git://github.com/wordpress-mobile/WordPress-Editor-iOS`, commit `1051403661ca8dbbdbc691b2bac8f30f1906cf15`)
- WordPress-iOS-Shared (= 0.2.2)
- WordPressApi (~> 0.3.1)
- WordPressApi (~> 0.3.4)
- WordPressCom-Analytics-iOS (= 0.0.26)
- WordPressCom-Stats-iOS (from `git://github.com/wordpress-mobile/WordPressCom-Stats-iOS`, commit `3d9cc7988d0b8df44a76c817415d4b36b4201e49`)
- wpxmlrpc (~> 0.7)
Expand Down Expand Up @@ -200,14 +200,14 @@ CHECKOUT OPTIONS:
:git: git://github.com/wordpress-mobile/WordPressCom-Stats-iOS

SPEC CHECKSUMS:
1PasswordExtension: 37d1488cf049b8bc0811beb7b52a19f8f803f7c8
1PasswordExtension: 38b5be7dd6dbe786c98f15d51d50ad21150db60a
AFNetworking: 8bee59492a6ff15d69130efa4d0dc67e0094a52a
AMPopTip: dc5bdb3a88bc2ed0a7ac9799e0a5d47c5211721f
CocoaLumberjack: 205769c032b5fef85b92472046bcc8b7e7c8a817
CrashlyticsLumberjack: 192a08e07648e4e09d44052356b53ab839cc8a1b
CTAssetsPickerController: 319a91106b7b323446b39ab944a3f14db0a1ca46
DTCoreText: 84eb8ba2e70448fdd9d837540e371f9f587b65ba
DTFoundation: 721a63964fb9acd64cb8c9d3d1642ee60bac3d6a
DTFoundation: bea4e07459f0f88a5aa3b8258fab1576bbe2e58c
EmailChecker: e909e6d113fac7ad5e3c304fabce30fc4a79c80e
Google-Diff-Match-Patch: 1f9c0b972c351d9c0a4fee137eb96896460477cd
google-plus-ios-sdk: bb7b918c2ee0d5f5e389c4fddc06d71995481f67
Expand All @@ -234,7 +234,7 @@ SPEC CHECKSUMS:
WordPress-AppbotX: 8bb0ad23af141e85db282ce09b58e5b3604cf54c
WordPress-iOS-Editor: 0e53faba113a3b81439226acd4265835fe985bf6
WordPress-iOS-Shared: f66cc48dae11681d24c9abf36724a6ec28014409
WordPressApi: 95a1b20372c3a5052f4d3bc4d333f72009c3d986
WordPressApi: 099a644955625cbae926c668fc6f009a7f5972d8
WordPressCom-Analytics-iOS: 3616aae427dbe1bdec6169ed3e1ac190af63f09e
WordPressCom-Stats-iOS: 1aeb8c7279bd5ef5a4b6528696360d1315352637
wpxmlrpc: 75ad2e4663c3a65948f5ae0799d948a8445bb0cf
Expand Down
6 changes: 6 additions & 0 deletions WordPress/Classes/Categories/UIDevice+Helpers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#import <UIKit/UIKit.h>

@interface UIDevice (Helpers)
- (NSString *)wordPressUserAgent;
- (NSString *)wordPressIdentifier;
@end
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
#import "UIDevice+WordPressIdentifier.h"
#import "UIDevice+Helpers.h"

static NSString * const WordPressIdentifierDefaultsKey = @"WordPressIdentifier";

@implementation UIDevice (WordPressIdentifier)
@implementation UIDevice (Helpers)

- (NSString *)wordpressIdentifier
- (NSString *)wordPressUserAgent
{
NSString *appVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
NSString *userAgent = [NSString stringWithFormat:@"wp-iphone/%@ (%@ %@, %@) Mobile",
appVersion,
self.systemName,
self.systemVersion,
self.model];

return userAgent;
}

- (NSString *)wordPressIdentifier
{
NSString *uuid;
if ([[UIDevice currentDevice] respondsToSelector:@selector(identifierForVendor)]) {
Expand Down
5 changes: 0 additions & 5 deletions WordPress/Classes/Categories/UIDevice+WordPressIdentifier.h

This file was deleted.

4 changes: 2 additions & 2 deletions WordPress/Classes/Models/Blog+Jetpack.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ - (void)validateJetpackUsername:(NSString *)username

AFHTTPRequestOperationManager* operationManager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:[NSURL URLWithString:BlogJetpackApiBaseUrl]];

NSString* userAgent = [[WordPressAppDelegate sharedWordPressApplicationDelegate] applicationUserAgent];
NSString *userAgent = [[WordPressAppDelegate sharedWordPressApplicationDelegate] applicationUserAgent];

operationManager.requestSerializer = [[AFJSONRequestSerializer alloc] init];
[operationManager.requestSerializer setAuthorizationHeaderFieldWithUsername:username password:password];
Expand Down Expand Up @@ -157,7 +157,7 @@ - (void)saveJetpackUsername:(NSString *)username
password:password
success:^(NSString *authToken) {
AccountService *accountService = [[AccountService alloc] initWithManagedObjectContext:self.managedObjectContext];
WPAccount *account = [accountService createOrUpdateWordPressComAccountWithUsername:username password:password authToken:authToken];
WPAccount *account = [accountService createOrUpdateWordPressComAccountWithUsername:username authToken:authToken];
self.jetpackAccount = account;
[account addJetpackBlogsObject:self];
[self dataSave];
Expand Down
1 change: 1 addition & 0 deletions WordPress/Classes/Models/Blog.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
@property (nonatomic, weak, readonly) NSString *version;
@property (nonatomic, strong, readonly) NSString *username;
@property (nonatomic, strong, readonly) NSString *password;
@property (nonatomic, strong, readonly) NSString *authToken;


/**
Expand Down
14 changes: 7 additions & 7 deletions WordPress/Classes/Models/Blog.m
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,8 @@ - (void)setXmlrpc:(NSString *)xmlrpc
- (NSArray *)getXMLRPCArgsWithExtra:(id)extra
{
NSMutableArray *result = [NSMutableArray array];
NSString *password = self.password;
if (!password) {
password = @"";
}
NSString *password = self.password ?: [NSString string];

[result addObject:self.blogID];
[result addObject:self.username];
[result addObject:password];
Expand Down Expand Up @@ -342,10 +340,12 @@ - (NSString *)username

- (NSString *)password
{
WPAccount *account = self.account;
NSString *password = account.password ?: @"";
return self.account.password ?: @"";
}

return password;
- (NSString *)authToken
{
return self.account.authToken;
}

- (BOOL)supportsFeaturedImages
Expand Down
2 changes: 1 addition & 1 deletion WordPress/Classes/Models/WPAccount.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
@property (nonatomic, strong) Blog *defaultBlog;

/**
The account's password
The self hosted account's password

Note that the password is stored using the keychain, not core data
*/
Expand Down
4 changes: 4 additions & 0 deletions WordPress/Classes/Models/WPAccount.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ - (void)didTurnIntoFault

- (NSString *)password
{
if (self.isWpcom) {
return nil;
}

return [SFHFKeychainUtils getPasswordForUsername:self.username andServiceName:self.xmlrpc error:nil];
}

Expand Down
6 changes: 5 additions & 1 deletion WordPress/Classes/Networking/PostServiceRemoteXMLRPC.m
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ - (void)updatePost:(RemotePost *)post
success:(void (^)(RemotePost *))success
failure:(void (^)(NSError *))failure
{
NSParameterAssert([post.postID integerValue] > 0);
NSParameterAssert(post.postID.integerValue > 0);
NSParameterAssert(blog.username);
NSParameterAssert(blog.password);

if ([post.postID integerValue] <= 0) {
if (failure) {
NSDictionary *userInfo = @{NSLocalizedDescriptionKey: @"Can't edit a post if it's not in the server"};
Expand All @@ -127,6 +130,7 @@ - (void)updatePost:(RemotePost *)post

NSDictionary *extraParameters = [self parametersWithRemotePost:post];
NSArray *parameters = @[post.postID, blog.username, blog.password, extraParameters];

[self.api callMethod:@"metaWeblog.editPost"
parameters:parameters
success:^(AFHTTPRequestOperation *operation, id responseObject) {
Expand Down
11 changes: 7 additions & 4 deletions WordPress/Classes/Services/AccountService.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,11 @@ extern NSString *const WPAccountEmailAndDefaultBlogUpdatedNotification;
Uses a background managed object context.

@param username the WordPress.com account's username
@param password the WordPress.com account's password
@param authToken the OAuth2 token returned by signIntoWordPressDotComWithUsername:password:success:failure:
@param authToken the OAuth2 token returned by signIntoWordPressDotComWithUsername:authToken:
@return a WordPress.com `WPAccount` object for the given `username`
@see createOrUpdateWordPressComAccountWithUsername:password:authToken:context:
@see createOrUpdateWordPressComAccountWithUsername:authToken:
*/
- (WPAccount *)createOrUpdateWordPressComAccountWithUsername:(NSString *)username
password:(NSString *)password
authToken:(NSString *)authToken;

/**
Expand Down Expand Up @@ -94,4 +92,9 @@ extern NSString *const WPAccountEmailAndDefaultBlogUpdatedNotification;
*/
- (void)updateEmailAndDefaultBlogForWordPressComAccount:(WPAccount *)account;

/**
Removes your default WordPress.com password from the keychain, if needed.
*/
- (void)removeWordPressComAccountPasswordIfNeeded;

@end
24 changes: 19 additions & 5 deletions WordPress/Classes/Services/AccountService.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#import "NSString+XMLExtensions.h"

static NSString * const DefaultDotcomAccountUUIDDefaultsKey = @"AccountDefaultDotcomUUID";
static NSString * const DefaultDotcomAccountPasswordRemovedKey = @"DefaultDotcomAccountPasswordRemovedKey";

@interface AccountService ()

Expand Down Expand Up @@ -150,16 +151,14 @@ - (void)removeDefaultWordPressComAccount
Uses a background managed object context.

@param username the WordPress.com account's username
@param password the WordPress.com account's password
@param authToken the OAuth2 token returned by signIntoWordPressDotComWithUsername:password:success:failure:
@param authToken the OAuth2 token returned by signIntoWordPressDotComWithUsername:authToken:
@return a WordPress.com `WPAccount` object for the given `username`
@see createOrUpdateWordPressComAccountWithUsername:password:authToken:context:
@see createOrUpdateWordPressComAccountWithUsername:password:authToken:
*/
- (WPAccount *)createOrUpdateWordPressComAccountWithUsername:(NSString *)username
password:(NSString *)password
authToken:(NSString *)authToken
{
WPAccount *account = [self createOrUpdateSelfHostedAccountWithXmlrpc:WordPressDotcomXMLRPCKey username:username andPassword:password];
WPAccount *account = [self createOrUpdateSelfHostedAccountWithXmlrpc:WordPressDotcomXMLRPCKey username:username andPassword:nil];
account.authToken = authToken;
account.isWpcom = YES;
[[ContextManager sharedInstance] saveContext:self.managedObjectContext];
Expand Down Expand Up @@ -251,4 +250,19 @@ - (void)updateEmailAndDefaultBlogForWordPressComAccount:(WPAccount *)account
}];
}

- (void)removeWordPressComAccountPasswordIfNeeded
{
// Let's do this just once!
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults boolForKey:DefaultDotcomAccountPasswordRemovedKey]) {
return;
}

WPAccount *account = [self defaultWordPressComAccount];
account.password = nil;

[defaults setBool:YES forKey:DefaultDotcomAccountPasswordRemovedKey];
[defaults synchronize];
}

@end
Loading