@@ -29,6 +29,10 @@ - (StaticContentTableViewSection *)oAuthSection {
29
29
return [StaticContentTableViewSection sectionWithTitle: @" OAuth" cells: @[
30
30
[StaticContentTableViewCell cellWithTitle: @" Sign in with Google"
31
31
action: ^{ [weakSelf signInGoogleHeadfulLite ]; }],
32
+ [StaticContentTableViewCell cellWithTitle: @" Link with Google"
33
+ action: ^{ [weakSelf linkWithGoogleHeadfulLite ]; }],
34
+ [StaticContentTableViewCell cellWithTitle: @" Reauthenticate with Google"
35
+ action: ^{ [weakSelf reauthenticateWithGoogleHeadfulLite ]; }],
32
36
[StaticContentTableViewCell cellWithTitle: @" Sign in with Twitter"
33
37
action: ^{ [weakSelf signInTwitterHeadfulLite ]; }],
34
38
[StaticContentTableViewCell cellWithTitle: @" Sign in with GitHub"
@@ -75,6 +79,68 @@ - (void)signInGoogleHeadfulLite {
75
79
}];
76
80
}
77
81
82
+ - (void )linkWithGoogleHeadfulLite {
83
+ FIROAuthProvider *provider = self.googleOAuthProvider ;
84
+ provider.customParameters = @{
85
+ @" prompt" : @" consent" ,
86
+ };
87
+ provider.scopes = @[ @" profile" , @" email" , @" https://www.googleapis.com/auth/plus.me" ];
88
+ [self showSpinner: ^{
89
+ [[AppManager auth ].currentUser linkWithProvider: provider
90
+ UIDelegate: nil
91
+ completion: ^(FIRAuthDataResult *_Nullable authResult,
92
+ NSError *_Nullable error) {
93
+ [self hideSpinner: ^{
94
+ if (error) {
95
+ [self logFailure: @" Reauthenticate with provider (Google) failed" error: error];
96
+ } else if (authResult.additionalUserInfo ) {
97
+ [self logSuccess: [self stringWithAdditionalUserInfo: authResult.additionalUserInfo]];
98
+ if (self.isNewUserToggleOn ) {
99
+ NSString *newUserString = authResult.additionalUserInfo .newUser ?
100
+ @" New user" : @" Existing user" ;
101
+ [self showMessagePromptWithTitle: @" New or Existing"
102
+ message: newUserString
103
+ showCancelButton: NO
104
+ completion: nil ];
105
+ }
106
+ }
107
+ [self showTypicalUIForUserUpdateResultsWithTitle: @" Link Error" error: error];
108
+ }];
109
+ }];
110
+ }];
111
+ }
112
+
113
+ - (void )reauthenticateWithGoogleHeadfulLite {
114
+ FIROAuthProvider *provider = self.googleOAuthProvider ;
115
+ provider.customParameters = @{
116
+ @" prompt" : @" consent" ,
117
+ };
118
+ provider.scopes = @[ @" profile" , @" email" , @" https://www.googleapis.com/auth/plus.me" ];
119
+ [self showSpinner: ^{
120
+ [[AppManager auth ].currentUser reauthenticateWithProvider: provider
121
+ UIDelegate: nil
122
+ completion: ^(FIRAuthDataResult *_Nullable authResult,
123
+ NSError *_Nullable error) {
124
+ [self hideSpinner: ^{
125
+ if (error) {
126
+ [self logFailure: @" Link with provider (Google) failed" error: error];
127
+ } else if (authResult.additionalUserInfo ) {
128
+ [self logSuccess: [self stringWithAdditionalUserInfo: authResult.additionalUserInfo]];
129
+ if (self.isNewUserToggleOn ) {
130
+ NSString *newUserString = authResult.additionalUserInfo .newUser ?
131
+ @" New user" : @" Existing user" ;
132
+ [self showMessagePromptWithTitle: @" New or Existing"
133
+ message: newUserString
134
+ showCancelButton: NO
135
+ completion: nil ];
136
+ }
137
+ }
138
+ [self showTypicalUIForUserUpdateResultsWithTitle: @" Reauthenticate Error" error: error];
139
+ }];
140
+ }];
141
+ }];
142
+ }
143
+
78
144
- (void )signInTwitterHeadfulLite {
79
145
FIROAuthProvider *provider = self.twitterOAuthProvider ;
80
146
[self showSpinner: ^{
0 commit comments