verfication email & new auth domain

This commit is contained in:
2025-03-01 22:34:38 +01:00
parent 27242819e2
commit 4c19356188
7 changed files with 367 additions and 35 deletions

View File

@@ -2,9 +2,10 @@
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { Injectable, inject } from '@angular/core';
import { FirebaseApp } from '@angular/fire/app';
import { GoogleAuthProvider, UserCredential, createUserWithEmailAndPassword, getAuth, sendEmailVerification, signInWithEmailAndPassword, signInWithPopup } from 'firebase/auth';
import { GoogleAuthProvider, UserCredential, createUserWithEmailAndPassword, getAuth, signInWithEmailAndPassword, signInWithPopup } from 'firebase/auth';
import { firstValueFrom } from 'rxjs';
import { environment } from '../../environments/environment';
import { MailService } from './mail.service';
@Injectable({
providedIn: 'root',
@@ -13,6 +14,7 @@ export class AuthService {
private app = inject(FirebaseApp);
private auth = getAuth(this.app);
private http = inject(HttpClient);
private mailService = inject(MailService);
// Registrierung mit Email und Passwort
async registerWithEmail(email: string, password: string): Promise<UserCredential> {
@@ -41,7 +43,17 @@ async registerWithEmail(email: string, password: string): Promise<UserCredential
// E-Mail-Verifizierung mit den angepassten ActionCode-Einstellungen senden
if (userCredential.user) {
await sendEmailVerification(userCredential.user, actionCodeSettings);
//await sendEmailVerification(userCredential.user, actionCodeSettings);
this.mailService.sendVerificationEmail(userCredential.user.email).subscribe({
next: () => {
console.log('Verification email sent successfully');
// Erfolgsmeldung anzeigen
},
error: (error) => {
console.error('Error sending verification email', error);
// Fehlermeldung anzeigen
}
});
}
// Token, RefreshToken und ggf. photoURL speichern