Issue occurs when using Angular Firebase $createUser method

I'm stuck on this issue. I'm attempting to set up a user with AngularFire using $firebaseAuth instead of the deprecated FirebaseSimpleLogin, as advised in the documentation. I am confident that the form is submitting a valid email and password, but I keep receiving the following error in the console:

Error: Firebase.createUser failed: First argument must contain the key "email" with type "string"

You can view the code below. I am using a factory service to handle the $createUser method, and the error seems to be happening within that function as the subsequent console logs are not being triggered after the method returns. I have also tried using the code provided in the documentation without splitting it between controller and services, but I still encounter the same error. Any help would be greatly appreciated. Thank you!

ng-submit="register()" on Form element

$scope.register = function(){
        console.log($scope.user); // logs object correctly
        // Authentication is passed into the controller as a dependency
        Authentication.register($scope.user) 
            .then(function(){
                //This does NOT fire
                console.log("User created successfully!"); 
                Authentication.login($scope.user);<br>
            })
            .then(function(authData){
                console.log("Logged in as:", authData.uid);
            })
            .catch(function(error) {
                console.log('error');
                $scope.errorMessage = error.toString();
        });
};

Authentication factory service

var obj = {
    register: function(user){
        var obj = {email: user.email, password: user.password};
        console.log(obj); // works correctly
        //var auth has the reference to Firebase
        return auth.$createUser(obj);
    }   
};

Answer №1

UPDATE: To resolve this issue, it is recommended to upgrade to AngularFire version 0.9.1 or later.

UPDATE DETAILS: The latest AngularFire version, 0.9.1, now suggests using a single credentials parameter when calling authentication methods. The previous format, as used by the original questioner, has been deprecated and will be removed in a future release. We advise against using it.

I take full responsibility for the confusion in the documentation. I aimed to maintain some compatibility with the previous AngularFire API by having user management methods accept individual arguments instead of an argument object like the standard Firebase SDK. Unfortunately, this decision was not accurately reflected in the documentation and examples. Your code should now resemble the following:

auth.$createUser("<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="aadecfd9deeadecfd9de84c9c5c7">[email protected]</a>", "password").then(function() {
  console.log("User created successfully!");
}).catch(function(error) {
  console.log("Error:", error);
});

I will promptly update the documentation, but in the meantime, this answer should help you proceed without delays.

Answer №2

I encountered a similar issue while working on Angularfire version 1.1 or later (installed via Bower) from home. I am currently following the tutorial provided at and implementing the code for managing users.

The code functions properly with hard coded strings such as [email protected]. However, I discovered a workaround where adding + '' to the arguments of the object passed to $Auth.createUser() resolves the issue. It seems like the text entered for email and password fields as ng-model are not being recognized as strings?

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

JavaScript does not support the enumeration of programs

I'm currently working on a program that takes user input (library, authorName) and displays the titles of books written by the author. Here is an example library structure: let library = [ { author: 'Bill Gates', title: 'The Road Ah ...

What advantages come from caching the document object for improved performance?

Usually, I cache DOM objects used in a script. However, recently I found myself having to reference the document object within a jQuery wrapper. I started questioning whether caching $(document) is necessary since there's only one document object per ...

Once a session is established within a route, it cannot be accessed or utilized in any other routes within the

I am currently in the process of setting up sessions for my node.js app. To achieve this, I am utilizing modules such as "express", "express-session", and "express-mysql-session" to store the sessions in a database on my server. While my code works perfect ...

Exploring secure routes in Node.js with test cases using Mocha and Chai?

The function verifies whether the route is accessible or not function checkSessionCookieValidity(req, res, next) { if (!isValid(req.session)) { return res.status(401).json({ isLoggedIn: false }); } return next ...

Creating a Music Bingo game to ring in the New Year

Looking to create a Music Bingo game for New Year's Eve with randomized songs that can be selected, but experiencing an issue where nothing happens when you have 4 in a row. Attempted adding a submit button, but it doesn't trigger any action. Ide ...

Setting state back to default following the conditional rendering of a React component

Whenever the save button is clicked, I aim to display a snackbar component by updating the showSnackbar state to true. To achieve this in React, it's just a simple conditional check in the main render method. The snackbar I'm using here automatic ...

Guide to dynamically generating Angular watchers within a loop

I'm looking to dynamically create angular watches on one or more model attributes. I attempted the following approach: var fields = ['foo', 'bar']; for (var i=0, n=fields.length; i<n; i++) { $scope.$watch('vm.model.&ap ...

Upon installing a global npm package, the system encountered an error stating: 'File or directory not found: ENOENT'

After successfully publishing my first Node.js CLI tool package on npm, I encountered an issue when trying to test it by installing it locally. The warning message "Error: ENOENT: no such file or directory" kept showing up. Steps for Reproduction To start ...

Tips for updating state in response to changes in props

I am working on a project where I have a Parent component that renders a large form. The Parent component has child components Child1 - Child4, which are responsible for rendering input fields. Whenever the props of the Parent component change, I need to ...

Cypress is having trouble loading a particular URL

I'm encountering a timeout error while trying to load a specific URL using Cypress. Even after setting the page load time to 2 minutes, the issue persists. Interestingly, general URLs like https://www.google.co.nz/ load without any problems. it(' ...

Switch out HTML dynamically using JavaScript/JQuery, embracing the principles of DRY coding

As a newcomer to front-end development, one issue I frequently encounter is avoiding repetition when dynamically generating HTML using JS/jQuery. Imagine you have a DOM object that has various states. Typically, all you need to do with JS is switch betwee ...

Sending a file stream with specific file name and extension in NodeJS: A comprehensive guide

Currently, I am utilizing nodejs to transmit file streams to express response var fileReadStream = fs.createReadStream(filePath); fileReadStream.pipe(res); However, the issue arises on the front-end where the file is solely downloadable with the "download ...

Using JavaScript to transform JSON information into Excel format

I have tried various solutions to my problem, but none seem to fit my specific requirement. Let me walk you through what I have attempted. function JSONToCSVConvertor(JSONData, ReportTitle, ShowLabel) { //If JSONData is not an object then JSON.parse will ...

Unable to select image inside linked container

I'm attempting to display a dropdown menu when the user clicks on the gear-img div using jQuery. However, because it's wrapped inside an a tag, clicking redirects me to a URL. I also want the entire div to be clickable. Any suggestions for a solu ...

Click on the hyperlinks one by one that trigger ajax events

There is a feature on the popular social media platform reddit.com where you can load more comments by clicking a link. I understand that comments may be hidden for performance reasons, but I would like to automatically expand all comments without having t ...

Solution: Resolve clientY scrolling issue within an HTML document

I am facing an issue with the positioning of my context menu. When I right-click and scroll down, the menu does not maintain its regular position. Instead of appearing to the right of the mouse cursor when stationary, it moves below the cursor based on how ...

Is there a way to eliminate the black seam that is visible on my floor mesh that has been separated? I am utilizing A

I recently imported a large .glb file into AFrame. The model has baked textures and the floor is divided into multiple mesh parts for improved resolution. However, I am facing an issue where black seams appear on the separated parts of the floor, only dis ...

Using TypeORM in Javascript to create routes efficiently

After examining the TypeORM websites examples, I noticed that some of them demonstrate routing usage using TypeScript. Given that TypeORM has the capability to use JavaScript instead of TypeScript, I am seeking guidance on how to implement Express routing ...

`Need to clean parameters for safe use in JavaScript code?`

I am working with the php code below: <?php $redirect_lp = $_GET['lp']; ?> <script> setTimeout(function(){ window.location.href = "<?php echo $redirect_lp; ?>"; }, 10) </script> How can I properly sanitiz ...

What are some effective ways to test React Router using Jest?

Just starting out with Jest testing and looking to test the code below. import React from "react"; import "./ButtonLogin.css"; import { Link } from 'react-router-dom'; function ButtonLogin() { return ( <Link to ...