Skip to content

Commit

Permalink
Added default expiry date to one hour for providers that don't return…
Browse files Browse the repository at this point in the history
… expires field
  • Loading branch information
william26 committed Oct 31, 2014
1 parent 36a2aa1 commit d4dedc7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
Binary file modified Dist/OAuthiOS.framework/Versions/A/OAuthiOS
Binary file not shown.
4 changes: 2 additions & 2 deletions OAuth.io.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
#

s.name = "OAuth.io"
s.version = "1.2.0"
s.version = "1.2.1"
s.summary = "OAuth that just works!"

s.description = <<-DESC
Expand Down Expand Up @@ -71,7 +71,7 @@ Pod::Spec.new do |s|
# Supports git, hg, bzr, svn and HTTP.
#

s.source = { :git => "https://github.com/oauth-io/oauth-ios.git", :tag => "1.2.0" }
s.source = { :git => "https://github.com/oauth-io/oauth-ios.git", :tag => "1.2.1" }


# ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<key>OAuthiOS.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
Expand Down
11 changes: 10 additions & 1 deletion OAuthiOS/Src/OAuthIOModal.m
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,17 @@ - (void)showWithProvider:(NSString *)provider options:(NSDictionary*)options
NSDictionary *json_d = [NSJSONSerialization JSONObjectWithData:[json dataUsingEncoding:NSUTF8StringEncoding] options: NSJSONReadingMutableContainers error:nil];
NSNumber *expires = [[json_d objectForKey:@"data"] objectForKey:@"expires"];
NSTimeInterval interval = [expires doubleValue];
NSDate *expiring_date = [[NSDate alloc] initWithTimeIntervalSince1970:interval];
NSDate *now = [[NSDate alloc] init];
NSDate *expiring_date;

if (expires != nil) {
expiring_date = [[NSDate alloc] initWithTimeIntervalSince1970:interval];
} else {
// If no expiry date is available, defaults to one hour
interval = 3600;
expiring_date = [[NSDate alloc] initWithTimeIntervalSinceNow:interval];
}

if ([now compare:expiring_date] == NSOrderedAscending)
{
@try {
Expand Down

0 comments on commit d4dedc7

Please sign in to comment.