I have an application in Angular 16, but when I register a new user in Firebase Authentication, it automatically logs in and replaces the current session with the new registration, when what I really want is for it to register the new email and keep my current session.
register({ email, password, name, phone, address, country, city }: any) {
return createUserWithEmailAndPassword(this.auth, email, password)
.then(async(userCredential) => {
//The user has registered successfully.
//Now, create a new document in the 'users' collection with the same UID.
return this.db.collection('users').doc(userCredential.user.uid).set({
registration_date: this.currentDate,
lastUpdate_date: this.currentDate,
lastUpdate: this.currentDate,
status: true,
email: email,
password: password,
name: name,
phone: phone,
address: address,
country: country,
city: city,
uid: userCredential.user.uid,
profile_picture: ''
});
});
}
Please, if someone can tell me what I should do to prevent it from automatically logging in upon registration, but rather keep the current user authenticated, or if I should do it differently, thank you.