Great. Here is my service on my platform to do just this. I want to know what you think about it. import { Component, OnInit } from '@angular/core';
import { environment } from 'src/environments/environment';
import firebase from 'firebase/compat/app';
import { AngularFireAuth } from '@angular/fire/compat/auth';
import { UserFlow } from 'src/app/\_models/enums';
import { iUser } from 'src/app/\_models/user';
import { ActivatedRoute, Router } from '@angular/router';
import { AppService } from 'src/app/\_services/app.service';
import { DataHelperService } from 'src/app/\_services/data-helper.service';
import { LoaderService } from 'src/app/\_services/loader.service';
import { UserAuthService } from 'src/app/\_services/user-auth.service';
import { Subscription } from 'rxjs';
import { ScholarshipService } from 'src/app/\_services/scholarship.service';
import { StateManagementService } from 'src/app/\_services/state-management.service';
import { UsersService } from 'src/app/\_services/users.service';
import { AngularFirestore } from '@angular/fire/compat/firestore';
import { MerekaStatus } from 'src/app/\_utils/status.enum';
declare var window: any;

@Component({
 selector: 'app-mereka-google-one-tap',
 templateUrl: './mereka-google-one-tap.component.html',
 styleUrls: ['./mereka-google-one-tap.component.scss']
})
export class MerekaGoogleOneTapComponent implements OnInit {
 user: iUser = new iUser();
 private $subscribers: Subscription[] = [];
 ngOnInit(): void {
 window.google.accounts?.id.initialize({
 client\_id: environment.oneTapClient,
 callback: (token) => {
 this.loginWithProvider(token);
 }
 });
 this.fireAuth.onAuthStateChanged((user) => {
 console.log(user);
 if (!user) {
 window.google.accounts.id.prompt();
 }
 });
 }

 loginWithProvider(token) {
 this.\_loaderService.start();
 firebase
 .auth()
 .signInWithCredential(firebase.auth.GoogleAuthProvider.credential(token.credential)
 )
 .then((result) => {
 // The signed-in user info.
 var user = result.user;
 this.$subscribers.push(
 this.usersService.getleanerUser(user.uid).subscribe(async (response) => {
 if (!response) {
 var data = {
 uid: user.uid,
 email: user.email,
 fullName: user.displayName,
 timestamp: Number(new Date()),
 };
 this.saveDatatoUserTableAfterRegister(data, user.uid);
 } else {
 await this.getUserData(user.uid);

 }
 this.\_loaderService.stop();
 })
 );
 })
 .catch((error) => {
 this.\_loaderService.stop();
 var errorMessage = error.message;

 this.dataHelper.publishSomeData({ showError: errorMessage });
 });
 }
 async saveDatatoUserTableAfterRegister(userData, uid: string) {
 userData.uid = uid;
 userData.timestamp = Number(new Date());
 await this.usersService.userEmail(userData.email, uid);
 this.angularFirestore
 .collection(`users`)
 .doc(uid)
 .collection('profiles')
 .doc('learnerProfile')
 .set({
 ...userData,
 createdDate: new Date(),
 })
 .then(async () => {
 console.log('Hello');

 await this.getUserData(uid);
 const userRole = localStorage.getItem('userRole');
 this.dataHelper.displayLoading = false;
 await this.userAuth.setUser(userData);
 this.dataHelper.publishSomeData({
 showSuccess: 'Account Created Successfully!',
 });
 })
 .catch((e) => {
 this.dataHelper.displayLoading = false;
 this.dataHelper.publishSomeData({ showError: e.message });
 });
 }
 async getUserData(uid: string) {
 const self = this;
 await this.\_scholarshipService.expireScholarCreditScore(uid);
 this.$subscribers.push(
 this.usersService.view(uid).subscribe(async (response) => {
 const user = response.learnerProfile;
 if (user) {
 self.dataHelper.displayLoading = false;
 await self.userAuth.setUser(user);
 self.dataHelper.publishSomeData({ showSuccess: 'User Logged In' });
 const userFlow = self.appService.getUserFlow();
 const userRole = localStorage.getItem('userRole');
 await this.\_stateManagementService.setDataToStatemanagement(uid);
 if (userFlow === UserFlow.HUB) {
 self.router.navigate(['/hub-onboard/form']);
 } else if (userFlow === UserFlow.SUBSCRIPTION) {
 const redirectTo = self.appService.redirectTo;

 if (!this.\_stateManagementService.userAgency) {
 self.router.navigateByUrl('welcome/hub');
 } else if (this.\_stateManagementService.userAgency.isApproved) {
 self.appService.redirectTo = undefined;
 this.appService.clearUserFlow();
 self.router.navigateByUrl(redirectTo);
 } else {
 self.appService.redirectTo = undefined;
 this.appService.clearUserFlow();
 self.router.navigate([], { queryParams: { plan: null }, queryParamsHandling: 'merge' });
 }
 } else if (userRole === 'expert') {
 self.router.navigate(['/expert-onboarding']);
 } else if (userRole === 'scholars') {
 this.$subscribers.push(
 this.\_activeRoute.queryParams.subscribe((params) => {
 if (params.mode === 'scholars') {
 if (params.lang) {
 localStorage.setItem('translateType', params.lang);
 }
 }
 })
 );

 this.router.navigate(['/welcome/scholar']);
 } else {
 console.log("hi");
 if (localStorage.getItem('redirectTo')) {
 console.log("hi2");
 localStorage.removeItem('redirectTo');
 } else {
 if (!(this.\_stateManagementService.userData && this.\_stateManagementService.userData.learnerProfile && this.\_stateManagementService.userData.learnerProfile.status == MerekaStatus.COMPLETED)) {
 this.router.navigate(['/learner-onboard']);
 }
 }
 }

 } else {
 self.userAuth.logoutUser();
 self.dataHelper.displayLoading = false;
 }
 })
 );
 }
 constructor(
 private fireAuth: AngularFireAuth,
 public dataHelper: DataHelperService,
 public userAuth: UserAuthService,
 public appService: AppService,
 public router: Router,
 private \_loaderService: LoaderService,
 public usersService: UsersService,
 public \_scholarshipService: ScholarshipService,
 private \_stateManagementService: StateManagementService,
 private \_activeRoute: ActivatedRoute,
 private angularFirestore: AngularFirestore,
 ) { }
}
reat. 다음은 제 플랫폼에서 이 작업을 수행하는 제 서비스입니다. '@angular/core'에서 { Component, OnInit }을 가져옵니다;'src/environments/environment'에서 { environment }를 임포트합니다;'firebase/compat/app'에서 firebase를 임포트합니다;'@angular/fire/compat/auth'에서 { AngularFireAuth }를 임포트합니다;'src/app/\_models/enums'에서 { UserFlow }를 임포트합니다;'src/app/\_models/user'에서 { iUser }를 임포트합니다;'@angular/router'에서 { ActivatedRoute, 라우터 }를 임포트합니다;'src/app/\_services/app.service'에서 { AppService }를 임포트합니다;'src/app/\_services/data-helper.service'에서 { DataHelperService }를 임포트합니다;'src/app/\_services/loader.service'에서 { LoaderService }를 임포트합니다;'src/app/\_services/user-auth.service'에서 { UserAuthService }를 임포트합니다;'rxjs'에서 { Subscription }을 임포트합니다;'src/app/\_services/scholarship.service'에서 { ScholarshipService }를 임포트합니다;'src/app/\_services/state-management.service'에서 { StateManagementService }를 임포트합니다;'src/app/\_services/users.service'에서 { UsersService }를 임포트합니다;import { AngularFirestore } '@angular/fire/compat/firestore'에서 가져옵니다;'src/app/\_utils/status.enum'에서 { MerekaStatus }를 임포트합니다;선언 var window: any;컴포넌트({ selector: 'app-mereka-google-one-tap', templateUrl: './mereka-google-one-tap.component.html', styleUrls: ['./mereka-google-one-tap.component.scss'] })})export class MerekaGoogleOneTapComponent 구현 OnInit { user: iUser = new iUser(); private $subscribers: Subscription[] = []; ngOnInit(): void { window.google.accounts?.id.initialize({ client\_id: environment.oneTapClient, callback: (토큰) => { this.loginWithProvider(토큰); } }); this.fireAuth.onAuthStateChanged((user) => { console.log(user); if (!user) { window.google.accounts.id.prompt(); } }); } loginWithProvider(토큰) { this.\_loaderService.start(); firebase .auth() .signInWithCredential(firebase.auth.GoogleAuthProvider.credential(token.credential) ) .then((결과) => { // 로그인한 사용자 정보입니다. var user = result.user; this.$subscribers.push( this.usersService.getleanerUser(user.uid).subscribe(async (response) => { if (!response) { var data = { 아이디: 사용자.아이디, 이메일: 사용자.이메일, fullName: user.displayName, timestamp: 숫자(새로운 날짜()), }; this.saveDatatoUserTableAfterRegister(data, user.uid); } else { await this.getUserData(user.uid); } this.\_loaderService.stop(); }) ); }) .catch((error) => { this.\_loaderService.stop(); var errorMessage = error.message; this.dataHelper.publishSomeData({ showError: errorMessage }); }); } async saveDatatoUserTableAfterRegister(userData, uid: 문자열) { userData.uid = uid; userData.timestamp = 숫자(새로운 날짜()); await this.usersService.userEmail(userData.email, uid); this.angularFirestore .collection(`users`) .doc(uid) .collection('profiles') .doc('learnerProfile') .set({ ...userData, createdDate: new Date(), }) .then(async () => { console.log('Hello'); await this.getUserData(uid); const userRole = localStorage.getItem('userRole'); this.dataHelper.displayLoading = false; await this.userAuth.setUser(userData); this.dataHelper.publishSomeData({ showSuccess: '계정이 성공적으로 생성되었습니다!', }); }) .catch((e) => { this.dataHelper.displayLoading = false; this.dataHelper.publishSomeData({ showError: e.message }); }); } async getUserData(uid: 문자열) { const self = this; await this.\_scholarshipService.expireScholarCreditScore(uid); this.$subscribers.push( this.usersService.view(uid).subscribe(async (response) => { const user = response.learnerProfile; if (user) { self.dataHelper.displayLoading = false; await self.userAuth.setUser(user); self.dataHelper.publishSomeData({ showSuccess: '사용자 로그인' }); const userFlow = self.appService.getUserFlow(); const userRole = localStorage.getItem('userRole'); await this.\_stateManagementService.setDataToStatemanagement(uid); if (userFlow === UserFlow.HUB) { self.router.navigate(['/hub-onboard/form']); } else if (userFlow === UserFlow.SUBSCRIPTION) { const redirectTo = self.appService.redirectTo; if (!this.\_stateManagementService.userAgency) { self.router.navigateByUrl('welcome/hub'); } else if (this.\_stateManagementService.userAgency.isApproved) { self.appService.redirectTo = 정의되지 않음; this.appService.clearUserFlow(); self.라우터.navigateByUrl(redirectTo); } else { self.appService.redirectTo = undefined; this.appService.clearUserFlow(); self.router.navigate([], { queryParams: { plan: null }, queryParamsHandling: 'merge' }); } } else if (userRole === 'expert') { self.router.navigate(['/expert-onboarding']); } else if (userRole === 'scholars') { this.$subscribers.push( this.\_activeRoute.queryParams.subscribe((params) => { if (params.mode === 'scholars') { if (params.lang) { localStorage.setItem('translateType', params.lang); } } }) ); this.router.navigate(['/welcome/scholar']); } else { console.log("hi"); if (localStorage.getItem('redirectTo')) { console.log("hi2"); localStorage.removeItem('re