diff --git a/src/app/auth.service.ts b/src/app/auth.service.ts index c662bc8..283b790 100644 --- a/src/app/auth.service.ts +++ b/src/app/auth.service.ts @@ -1,5 +1,5 @@ import {inject, Injectable} from '@angular/core'; -import {Auth, getRedirectResult, GoogleAuthProvider, idToken, signInWithPopup, signInWithRedirect, signOut, user, User} from '@angular/fire/auth'; +import {Auth, getRedirectResult, GoogleAuthProvider, idToken, signInWithRedirect, signOut, user, User} from '@angular/fire/auth'; import {BehaviorSubject, Subscription} from 'rxjs'; @Injectable({ @@ -28,12 +28,6 @@ export class AuthService { getRedirectResult(this.auth); // ignore result } - signInWithPopup() { - const provider = new GoogleAuthProvider(); - provider.setCustomParameters({hd: 'docchula.com'}); - return signInWithPopup(this.auth, provider); - } - signInWithRedirect() { const provider = new GoogleAuthProvider(); provider.setCustomParameters({hd: 'docchula.com'}); diff --git a/src/app/welcome/welcome.page.ts b/src/app/welcome/welcome.page.ts index 951776a..70f2c72 100644 --- a/src/app/welcome/welcome.page.ts +++ b/src/app/welcome/welcome.page.ts @@ -82,18 +82,14 @@ export class WelcomePage implements OnInit, OnDestroy { spinner: "crescent", }); await loading.present(); + await this.authService.signInWithRedirect().catch(async (error) => { + await this.alertError( + "Login Failed", + `Unable to sign in. Please try again. (${error.code}: ${error.message})` + ); + }) + .finally(() => loading.dismiss()); - this.authService.signInWithPopup().catch(async (error) => { - if (error.code === "auth/popup-closed-by-user") { - // User closed the popup without completing the sign-in. May cause by popup blocker. - await this.authService.signInWithRedirect(); - } else { - await this.alertError( - "Login Failed", - `Unable to sign in. Please try again. (${error.code}: ${error.message})`, - ); - } - }).finally(() => loading.dismiss()); } logout() {