MCPcopy Index your code
hub / github.com/codecombat/codecombat / onClickGPlusLoginButton

Method onClickGPlusLoginButton

app/views/core/AuthModal.js:164–235  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

162 // Google Plus
163
164 onClickGPlusLoginButton () {
165 const btn = this.$('#google-login-button')
166 return application.gplusHandler.connect({
167 context: this,
168 success (resp) {
169 if (resp == null) { resp = {} }
170 btn.find('.sign-in-blurb').text($.i18n.t('login.logging_in'))
171 btn.attr('disabled', true)
172 return application.gplusHandler.loadPerson({
173 resp,
174 context: this,
175 success (gplusAttrs) {
176 const existingUser = new User()
177 return existingUser.fetchGPlusUser(gplusAttrs.gplusID, gplusAttrs.email, {
178 success: () => {
179 return me.loginGPlusUser(gplusAttrs.gplusID, {
180 success: () => {
181 application.tracker.identifyAfterNextPageLoad()
182 return application.tracker.identify().finally(() => {
183 return loginNavigate(this.subModalContinue)
184 })
185 },
186 error: this.onGPlusLoginError,
187 })
188 },
189 error: (res, jqxhr) => {
190 if ((jqxhr.status === 409) && jqxhr.responseJSON.errorID && (jqxhr.responseJSON.errorID === 'account-with-email-exists')) {
191 const mergeLogin = (gplusAttrs) => {
192 return me.loginGPlusUser(gplusAttrs.gplusID, {
193 data: { merge: true, email: gplusAttrs.email },
194 success: () => {
195 application.tracker.identifyAfterNextPageLoad()
196 return application.tracker.identify().finally(() => {
197 return loginNavigate(this.subModalContinue)
198 })
199 },
200 error: this.onGPlusLoginError,
201 })
202 }
203
204 // auto-merge since we roster and create accounts for them
205 if (gplusAttrs.email?.includes(User.getNapervilleDomain())) {
206 return mergeLogin(gplusAttrs)
207 }
208 return noty({
209 text: $.i18n.t('login.accounts_merge_confirmation'),
210 layout: 'topCenter',
211 type: 'info',
212 buttons: [
213 {
214 text: 'Yes',
215 onClick ($noty) {
216 $noty.close()
217 return mergeLogin(gplusAttrs)
218 },
219 }, { text: 'No', onClick ($noty) { return $noty.close() } }],
220 })
221 } else {

Callers 1

initializeMethod · 0.95

Calls 1

connectMethod · 0.45

Tested by

no test coverage detected