Mono XRaider
Mono XRaider

Reputation: 21

Using Firebase without Google Auth for Username and Password Registration

I'm working on a project where I need to allow users to register using just a username and password, without relying on Google Auth. I'm using Firebase for my backend services. How can I implement user registration and authentication using only Firebase's services, without integrating Google Auth?

Specifically, I want users to be able to:

  1. Register with a username and password.
  2. Store these credentials securely in Firebase's database or just MySQL.
  3. Authenticate using these credentials for subsequent logins.

I've explored Firebase documentation, but most examples focus on integrating Google Auth alongside email/password authentication. Can someone provide guidance or point me to relevant resources on implementing this type of authentication flow solely with Firebase's built-in authentication and database services?

Thank you.

Currently, I'm still in the planning stage of my project and haven't started writing any code yet. My intention in posting this question is to gather insights and guidance on how to proceed with implementing user registration and authentication using Firebase without Google Auth.

In terms of what I've tried so far, I've primarily been exploring Firebase documentation and various online resources to understand the capabilities of Firebase's authentication and database services. However, most of the examples I've come across focus on integrating Google Auth alongside email/password authentication.

As for my expectations, I'm hoping to gain a better understanding of the steps involved in implementing a username/password registration system solely using Firebase's built-in authentication and database services. Additionally, guidance on whether to use a MySQL or SQL database with Firebase for this purpose would be greatly appreciated.

I understand that my question may be somewhat broad at this stage, but any advice or pointers on how to proceed would be invaluable as I begin development on this project.

As from my last above question, I indeed started writing the code but i am meeting hell a lot of errors , especially this one

Uncaught TypeError: auth.createUserWithEmailAndPassword is not a function
    at handleSubmit (Sign.jsx?t=1708196380343:72:10)
    at HTMLUnknownElement.callCallback2 (react-dom.development.js:4164:14)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:4213:16)
    at invokeGuardedCallback (react-dom.development.js:4277:31)
    at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4291:25)
    at executeDispatch (react-dom.development.js:9041:3)
    at processDispatchQueueItemsInOrder (react-dom.development.js:9073:7)
    at processDispatchQueue (react-dom.development.js:9086:5)
    at dispatchEventsForPlugins (react-dom.development.js:9097:3)
    at react-dom.development.js:9288:12

from this line of code that is imported in my SignUp.jsx with auth


auth.createUserWithEmailAndPassword(email, emailPass)
            .then((userCredential) => {
                // The user has been registered and signed in
                var user = userCredential.user;
                console.log('User registered:', user);
            })
            .catch((error) => {
                // Handle Errors here.
                var errorCode = error.code;
                var errorMessage = error.message;
                console.error('Error registering user:', errorCode, errorMessage);
            });

and this is how my firebase config looks like


// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getFirestore } from 'firebase/firestore'
import {getAuth, signInWithEmailAndPassword, createUserWithEmailAndPassword} from 'firebase/auth';

const firebaseConfig = {
    apiKey: "",
    authDomain: "",
    projectId: "",
    storageBucket: "",
    messagingSenderId: "",
    appId: ""
};

const app = initializeApp(firebaseConfig);
const auth = getAuth(app);

export { auth };

I really needs help because i am not understanding the error properly.

Upvotes: 1

Views: 350

Answers (1)

Alex Mamo
Alex Mamo

Reputation: 1

How can I implement user registration and authentication using only Firebase's services, without integrating Google Auth?

There is no need to implement any Google Auth if you only need to authenticate your users with email and password.

So,

  1. Register with a username and password.

This is exactly how it works.

  1. Store these credentials securely in Firebase's database or just MySQL.

Yes, the credentials are stored securely inside Firebase Authentication. There is also no need for any additional MySQL or any other type of database. Please also note, that this product has an out-of-the-box functionality and is free of charge up to 50k/month active users.

  1. Authenticate using these credentials for subsequent logins.

You can create a mechanism to remember the credentials that were been used.

Additionally, guidance on whether to use a MySQL or NoSQL database with Firebase for this purpose would be greatly appreciated.

If you want to store additional data of the user in a database, then it's up to you to decide what type of database to use. You can indeed use a SQL database, or you can also use a NoSQL database like Cloud Firestore or the Firebase Realtime Database.

Please see below a guide that can help you choose a database between Cloud Firestore and the Realtime Database:

Upvotes: 0

Related Questions