I wanted to add two features to my app - changing email and changing password. However, in the console there are no errors. I received information that the password/email was changed, but when I try to sign in with the new credentials, they don't work. However, the old credentials work.
const settingItem = vueRef('')
const currentPassword = vueRef('')
const newCredentials = vueRef('')
const changeSetting = () => {
const userId = getUserId()
const currentUser = auth.currentUser
const credentials = EmailAuthProvider.credential(currentUser.email, currentPassword.value)
if (settingItem.value == 'Username' && !newCredentials.value || settingItem.value != 'Username' && !currentPassword.value || !newCredentials.value) {
$q.notify({
type: 'negative',
message: 'Fill in all fields'
})
return
}
if (settingItem.value == 'Password') {
reauthenticateWithCredential(currentUser, credentials).then(() => {
updatePassword(currentUser, newCredentials.value).then((response) => {
$q.notify({
type: 'positive',
message: 'Password changed successfully.'
})
}).catch((error) => {
console.log('update error: ', error)
})
}).catch((error) => {
console.log('re auth error: ', error)
})
} else if (settingItem.value == 'Email') {
reauthenticateWithCredential(currentUser, credentials).then(() => {
updateEmail(currentUser, newCredentials.value).then(() => {
$q.notify({
type: 'positive',
message: 'Email changed successfully.'
})
}).catch((error) => {
console.log('update error: ', error)
})
}).catch((error) => {
console.log('re auth error: ', error)
})
} else if (settingItem.value == 'Username') {
console.log('username')
}
Does anyone know where the problem is?