#23: users table + insert/update added

This commit is contained in:
2025-02-13 10:56:03 -06:00
parent 5eee7c9ac4
commit d180cd70e8
19 changed files with 110 additions and 33 deletions

View File

@@ -1,11 +1,12 @@
import { CommonModule } from '@angular/common';
import { Component, inject } from '@angular/core';
import { Auth } from '@angular/fire/auth';
import { GoogleAuthProvider, signInWithPopup } from 'firebase/auth';
import { GoogleAuthProvider, signInWithPopup, UserCredential } from 'firebase/auth';
import { PopoverComponent } from './components/popover.component';
import { DeckListComponent } from './deck-list.component';
import { ClickOutsideDirective } from './service/click-outside.directive';
import { PopoverService } from './services/popover.service';
import { UserService } from './services/user.service';
@Component({
selector: 'app-root',
template: `
@@ -119,7 +120,7 @@ export class AppComponent {
private confirmCallback?: (inputValue?: string) => void;
private cancelCallback?: () => void;
constructor(public popoverService: PopoverService) {
constructor(public popoverService: PopoverService, private userService: UserService) {
this.popoverService.popoverState$.subscribe(options => {
this.popoverVisible = true;
this.popoverTitle = options.title;
@@ -147,7 +148,7 @@ export class AppComponent {
async loginWithGoogle() {
const provider = new GoogleAuthProvider();
try {
const result = await signInWithPopup(this.auth, provider);
const result: UserCredential = await signInWithPopup(this.auth, provider);
this.isLoggedIn = true;
this.photoURL = result.user.photoURL;
@@ -159,6 +160,8 @@ export class AppComponent {
this.showDropdown = false;
await this.userService.logIn({ name: result.user.displayName, email: result.user.email, sign_in_provider: result.providerId });
console.log('Logged in with Google', result.user);
} catch (error) {
console.error('Google Login failed', error);