verfication email & new auth domain
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { lastValueFrom } from 'rxjs';
|
||||
import { lastValueFrom, Observable } from 'rxjs';
|
||||
import { ShareByEMail } from '../../../../bizmatch-server/src/models/db.model';
|
||||
import { ErrorResponse, MailInfo } from '../../../../bizmatch-server/src/models/main.model';
|
||||
import { environment } from '../../environments/environment';
|
||||
@@ -18,4 +18,32 @@ export class MailService {
|
||||
async mailToFriend(shareByEMail: ShareByEMail): Promise<void | ErrorResponse> {
|
||||
return await lastValueFrom(this.http.post(`${this.apiBaseUrl}/bizmatch/mail/send2Friend`, shareByEMail));
|
||||
}
|
||||
/**
|
||||
* Sendet eine E-Mail-Verifizierung an die angegebene E-Mail-Adresse
|
||||
* @param email Die E-Mail-Adresse des Benutzers
|
||||
* @param redirectConfig Konfiguration für die Weiterleitung nach Verifizierung
|
||||
* @returns Observable mit der API-Antwort
|
||||
*/
|
||||
sendVerificationEmail(
|
||||
email: string,
|
||||
redirectConfig?: {
|
||||
protocol?: string,
|
||||
hostname?: string,
|
||||
port?: number
|
||||
}
|
||||
): Observable<any> {
|
||||
// Extrahiere aktuelle URL-Informationen, wenn nicht explizit angegeben
|
||||
const currentUrl = new URL(window.location.href);
|
||||
|
||||
const config = {
|
||||
protocol: redirectConfig?.protocol || currentUrl.protocol.replace(':', ''),
|
||||
hostname: redirectConfig?.hostname || currentUrl.hostname,
|
||||
port: redirectConfig?.port || (currentUrl.port ? parseInt(currentUrl.port) : undefined)
|
||||
};
|
||||
|
||||
return this.http.post(`${this.apiBaseUrl}/bizmatch/mail/verify-email`, {
|
||||
email,
|
||||
redirectConfig: config
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,8 @@ export const environment_base = {
|
||||
ipinfo_token: '7029590fb91214',
|
||||
firebaseConfig: {
|
||||
apiKey: 'AIzaSyBqVutQqdgUzwD9tKiKJrJq2Q6rD1hNdzw',
|
||||
authDomain: 'bizmatch-net.firebaseapp.com',
|
||||
//authDomain: 'bizmatch-net.firebaseapp.com',
|
||||
authDomain: 'auth.bizmatch.net',
|
||||
projectId: 'bizmatch-net',
|
||||
storageBucket: 'bizmatch-net.firebasestorage.app',
|
||||
messagingSenderId: '1065122571067',
|
||||
|
||||
Reference in New Issue
Block a user