I created a form to create user profiles. But whenever I create a user I have a problem. Logged in and logged out user. Please help to solve this problem.
const successCreate = () => { createUserWithEmailAndPassword(auth, email.value, confirmPassword.value) .then(() => { db.collection('businessForm') .add({ schoolName: schoolName.value, board: board.value, subjects: [ subject1.value, subject2.value, subject3.value, subject4.value, subject5.value, subject6.value, subject7.value, subject8.value, ], email: email.value, street: street.value, city: city.value, state: state.value, mobile: mobile.value, telephone: telephone.value, isAdmin: true, }) .then(() => { isLoading.value = false notyf.success('Account created successfully!') }) .catch((err) => { isLoading.value = false notyf.error('Something went wrong. Try again later!') }) }) .catch((err) => { isLoading.value = false notyf.error('Something went wrong. Try again later!') }) }
Any solutions appreciated!
When you pass the createUserWithEmailAndPassword()
method of
Client JS SDK, the user will also log in to your application after success , as described in the documentation narrate. There is no way to avoid this.If you want to avoid the current user logging out (logout) and logging in as a newly created user, you need to implement a different method, such as calling the use of the Management SDK.
You may be interested in this article on how to use Callable Cloud Functions , a module that allows end users with a specific administrator role to create other users ( Disclaimer, I am the author).