1

I keep getting the error "The specified email address is invalid" in my Ember-Firebase app, even if I created an account just to test log in.

I'm wondering if it has to do with the way I'm passing information as a string?

initializer/emberfire.js

import Ember from 'ember';
import Firebase from 'firebase';


var session = Ember.Object.extend({
    ref : new Firebase("https://nutella.firebaseio.com"),

    addFirebaseCallback: function() {
        var session = this;
        var isNewUser = true;

        this.get("ref").onAuth(function(authData) {
            if (authData) {
                session.set("isAuthenticated", true);
            } else if (authData && isNewUser) {
                session.get("ref").child("users").child(authData.uid).set({
                    provider: authData.provider,
                    name: getName(authData)
                });
            } else {
                session.set("isAuthenticated", false);
            }
        });
    }.on("init"),

    createUser: function() {
        var session = this;
        return new Ember.RSVP.Promise(function(resolve, reject) {
            session.get('ref').createUser({
                        name: "",
                        email: "",
                        password: ""
            },

            function(error, userData) {
                    if (userData) {
                        resolve(userData.uid);
                        session.set("isNewUser", true);
                    } else {
                        reject(error);
                    }
                });
        });
    },

application.js

import Ember from 'ember';
import Firebase from 'firebase';

var ref = new Firebase("https://nutella.firebaseio.com");

export default Ember.Route.extend({
    actions: {
        createUser: function() {
            var controller = this;
            controller.get('session').createUser().then(function(user) {
                }, function() {
                });
        },

I'd really appreciate if you could point me in the right direction!

sunoceansand
  • 237
  • 3
  • 13

1 Answers1

0

Passing a string shouldn't be a problem. Here are a couple suggestions:


  1. (This may be obvious, but...) It seems like you're passing empty strings to createUser:
session.get('ref').createUser({
  name: "",
  email: "",
  password: ""
},

  1. Assuming that you removed the strings from the code on purpose, there is also the fact that you're passing Firebase.createUser() an extra argument, name.

In the .createUser() documentation, the arguments are listed as:

credentials Object
An object containing email and password attributes corresponding to the new user account.

onComplete Function
A callback function that will be called when the user account has been created. On failure, the first argument will be an Error object indicating the failure, with a machine-readable code attribute. On success, the first argument will be null, and the second argument will be an object containing attributes of the newly-created user, including the uid.

So, here is a revised version of your call to createUser():

session.get('ref').createUser({
  email: "some@user.com",
  password: "somepassword123"
},

If that doesn't do it, can you provide more info - where (line number) are you getting that error?

Hope that helps.

sbolel
  • 3,486
  • 28
  • 45