diff options
author | Zsika Phillip <protocol86@users.noreply.github.com> | 2018-04-03 17:19:51 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-03 17:19:51 -0700 |
commit | 6566328dc461c38c6000c64996c17883b9895d06 (patch) | |
tree | 1f072d106b95e87fbd9d163194d08c3a76977e07 /Example/Auth/Sample | |
parent | 1be9737fb28deb388cbcfaf6324ebad49683340b (diff) |
Adds copy auth state API (#1018)
* Adds copy auth state API
* improvements
* Addresses comments
Diffstat (limited to 'Example/Auth/Sample')
-rw-r--r-- | Example/Auth/Sample/MainViewController.m | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Example/Auth/Sample/MainViewController.m b/Example/Auth/Sample/MainViewController.m index 18f1e02..e343508 100644 --- a/Example/Auth/Sample/MainViewController.m +++ b/Example/Auth/Sample/MainViewController.m @@ -429,6 +429,11 @@ static NSString *const kRemoveIDTokenListenerTitle = @"Remove Last ID Token Chan */ static NSString *const kSectionTitleApp = @"APP"; +/** @var kUpdateCurrentUserFromSavedTitle + @brief The text of the "Upgrade to saved user" button. + */ +static NSString *const kUpdateCurrentUserFromSavedTitle = @"Upgrade to saved user"; + /** @var kCreateUserTitle @brief The text of the "Create User" button. */ @@ -745,6 +750,9 @@ typedef enum { }], ]], [StaticContentTableViewSection sectionWithTitle:kSectionTitleSignIn cells:@[ + [StaticContentTableViewCell cellWithTitle:kUpdateCurrentUserFromSavedTitle + value:nil + action:^{ [weakSelf updateToSavedUser]; }], [StaticContentTableViewCell cellWithTitle:kCreateUserTitle value:nil action:^{ [weakSelf createUser]; } @@ -2744,6 +2752,29 @@ static NSDictionary<NSString *, NSString *> *parseURL(NSString *urlString) { }]; } +/** @fn updateToSavedUser + @brief updates the current user to the saved user. + */ +- (void)updateToSavedUser { + if(![AppManager auth].currentUser) { + NSLog(@"You must be signed in to perform this action"); + return; + } + + if (!_userInMemory) { + NSLog(@"You need an in memory user to perform this action"); + return; + } + + [[AppManager auth] updateCurrentUser:_userInMemory completion:^(NSError *_Nullable error) { + if (error) { + [self showMessagePrompt: + [NSString stringWithFormat:@"An error Occurred: %@", error.localizedDescription]]; + return; + } + }]; +} + /** @fn createUser @brief Creates a new user. */ |