Closed urlsab closed 1 year ago
I see you have a console.log for the password only after a successful login. For debugging, I would suggest logging the email and password strings before creating the account (before createUserWithEmailAndPassword), and then again before signing in (before signInWithEmailAndPassword), just to make sure there isn't some error in your code processing the string that causes it to be empty or null before you pass it to the Firebase auth functions.
ok I'll do it
So - I logged both of them and I do get string of the currect password but only first login is working , right after creating new user. But when I'm trying to login again (after logout) - firestore forgetting my password or my account.
Here's the full description:
const onSubmitHandler = async (e) => {
e.preventDefault();
console.log(curAuth, emailAdd, rePassword);
await createUserWithEmailAndPassword(curAuth, emailAdd, rePassword)
.then((userCredential) => {
let userData = userCredential.user;
userData.displayName = rePassword;
userData.phoneNumber = firstName;
console.log(auth);
console.log(userData)
console.log(`the user password is: ${rePassword} `);
console.log(`displayName:${userData.displayName}`);
console.log(`phoneNumber:${userData.phoneNumber}`);
})
.catch((error) => {
const errorCode = error.code;
const errorMessage = error.message;
console.log(errorCode, errorMessage);
console.log("error from createUserWithEmailAndPassword function")
})
the logs before create user method:
AuthImpl {app: FirebaseAppImpl, heartbeatServiceProvider: Provider, config: {…}, currentUser: UserImpl, emulatorConfig: null, …} 'yairsabag213@gmail.com' 'mama1234'
[mama1234 is the correct password !]
const onLogin = async (e) => {
e.preventDefault();
console.log(curAuth, email, password);
await signInWithEmailAndPassword(curAuth, email, password)
.then((userCredential) => {
const user = userCredential.user;
console.log(user);
console.log(curAuth);
console.log(password);
navigate("/dashboard");
})
.catch((error) => {
const errorCode = error.code;
const errorMessage = error.message;
console.log(errorCode, errorMessage);
console.log(curAuth);
// alert(errorCode);
});
}
when I first time create the user , the login is working. But when I logout and try to login in again with password - it's not working !
the logs for fisrt time login after create new user and befor the method signin:
AuthImpl {app: FirebaseAppImpl, heartbeatServiceProvider: Provider, config: {…}, currentUser: UserImpl, emulatorConfig: null, …} 'yairsabag213@gmail.com' 'mama1234'
the logs for login after logout and try login second time - before the method sign in:
AuthImpl {app: FirebaseAppImpl, heartbeatServiceProvider: Provider, config: {…}, currentUser: null, emulatorConfig: null, …} 'yairsabag213@gmail.com' 'mama1234'
the logs after signin method:
POST https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=AIzaSyCEryolwTvi751-v2evqPUquUvlcugNys8 400 (Bad Request)
auth/wrong-password Firebase: Error (auth/wrong-password).
AuthImpl {app: FirebaseAppImpl, heartbeatServiceProvider: Provider, config: {…}, currentUser: null, emulatorConfig: null, …}
app
:
FirebaseAppImpl {_isDeleted: false, _options: {…}, _config: {…}, _name: '[DEFAULT]', _automaticDataCollectionEnabled: false, …}
authStateSubscription
:
Subscription {auth: AuthImpl, observer: ObserverProxy, addObserver: ƒ}
beforeStateQueue
:
AuthMiddlewareQueue {auth: AuthImpl, queue: Array(0)}
clientVersion
:
"Chrome/JsCore/9.17.1/FirebaseCore-web"
config
:
{apiKey: 'AIzaSyCEryolwTvi751-v2evqPUquUvlcugNys8', authDomain: 'resumes-builder.firebaseapp.com', clientPlatform: 'Browser', apiHost: 'identitytoolkit.googleapis.com', tokenApiHost: 'securetoken.googleapis.com', …}
currentUser
:
null
emulatorConfig
:
null
frameworks
:
[]
heartbeatServiceProvider
:
Provider {name: 'heartbeat', container: ComponentContainer, component: Component, instances: Map(1), instancesDeferred: Map(0), …}
idTokenSubscription
:
Subscription {auth: AuthImpl, observer: ObserverProxy, addObserver: ƒ}
isProactiveRefreshEnabled
:
true
languageCode
:
null
lastNotifiedUid
:
null
name
:
"[DEFAULT]"
operations
:
Promise {
I think i found the answer.
https://github.com/firebase/firebaseui-web/issues/122
Don't sign in firestore auth if your google accouny t is connected.
I tried another email/google account I know, that is not connected to my pc - and i succeeded login and time.
I'm glad you were able to resolve this issue on your own :)
Thanks
בתאריך יום ב׳, 13 במרץ 2023, 19:18, מאת Malcolm Deck < @.***>:
I'm glad you were able to resolve this issue on your own :)
— Reply to this email directly, view it on GitHub https://github.com/firebase/firebase-js-sdk/issues/7109#issuecomment-1466573893, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASLT576XSHASZGK3FE6M5KLW35JF5ANCNFSM6AAAAAAVU5UYSM . You are receiving this because you authored the thread.Message ID: @.***>
The login works only for the first time after you just create a new account, but when you logout - firestore forget the password or see that as null
on consloe i get: auth/wrong-password Firebase: Error (auth/wrong-password).
And here my code: [consider all imports etc]