Skip to content

Instantly share code, notes, and snippets.

@frosty
Created August 9, 2016 20:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frosty/9ebcf3aececcf3f0684059e40147b95f to your computer and use it in GitHub Desktop.
Save frosty/9ebcf3aececcf3f0684059e40147b95f to your computer and use it in GitHub Desktop.
diff --git a/Simperium/SPAuthenticator.h b/Simperium/SPAuthenticator.h
index 6148933..83c1a54 100644
--- a/Simperium/SPAuthenticator.h
+++ b/Simperium/SPAuthenticator.h
@@ -22,6 +22,7 @@ typedef void(^FailedBlockType)(int responseCode, NSString *responseString);
@protocol SPAuthenticatorDelegate <NSObject>
@optional
- (void)authenticationDidSucceedForUsername:(NSString *)username token:(NSString *)token;
+- (void)authenticationDidCreateAccount;
- (void)authenticationDidFail;
- (void)authenticationDidCancel;
@end
diff --git a/Simperium/SPAuthenticator.m b/Simperium/SPAuthenticator.m
index f920d69..32a5eda 100644
--- a/Simperium/SPAuthenticator.m
+++ b/Simperium/SPAuthenticator.m
@@ -200,6 +200,15 @@ - (void)authDidSucceed:(SPHttpRequest *)request {
[self performSelector:@selector(delayedAuthenticationDidFinish) withObject:nil afterDelay:0.1];
}
+- (void)authWithCreationDidSucceed:(SPHttpRequest *)request
+{
+ [self authDidSucceed:request];
+
+ if ([self.delegate respondsToSelector:@selector(authenticationDidCreateAccount)]) {
+ [self.delegate authenticationDidCreateAccount];
+ }
+}
+
- (void)authDidFail:(SPHttpRequest *)request {
if (self.failedBlock) {
self.failedBlock(request.responseCode, request.responseString);
@@ -250,7 +259,7 @@ - (void)createWithUsername:(NSString *)username password:(NSString *)password su
// Selectors are for auth-related handling
request.delegate = self;
- request.selectorSuccess = @selector(authDidSucceed:);
+ request.selectorSuccess = @selector(authWithCreationDidSucceed:);
request.selectorFailed = @selector(authDidFail:);
[[SPHttpRequestQueue sharedInstance] enqueueHttpRequest:request];
diff --git a/Simperium/Simperium.h b/Simperium/Simperium.h
index fd94f4e..0bbad57 100644
--- a/Simperium/Simperium.h
+++ b/Simperium/Simperium.h
@@ -58,6 +58,7 @@ typedef NS_ENUM(NSInteger, SPSimperiumErrors) {
- (void)simperiumDidLogin:(Simperium *)simperium;
- (void)simperiumDidLogout:(Simperium *)simperium;
- (void)simperiumDidCancelLogin:(Simperium *)simperium;
+- (void)simperiumDidCreateAccount:(Simperium *)simperium;
@end
diff --git a/Simperium/Simperium.m b/Simperium/Simperium.m
index 8e0ab52..72615c1 100644
--- a/Simperium/Simperium.m
+++ b/Simperium/Simperium.m
@@ -765,6 +765,13 @@ - (void)authenticationDidSucceedForUsername:(NSString *)username token:(NSString
}
}
+- (void)authenticationDidCreateAccount
+{
+ if ([self.delegate respondsToSelector:@selector(simperiumDidCreateAccount:)]) {
+ [self.delegate simperiumDidCreateAccount:self];
+ }
+}
+
- (void)authenticationDidCancel {
[self stopNetworkManagers];
[self.authenticator reset];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment