question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

transitionTo doesn't work in user creation

See original GitHub issue

Hi everyone.

I’m having a little issue when I create a user, in “then” callback doesn’t change to index route until I refresh the page, can you help me please? I think I’m doing as the torii-emberfire-firebase documentation.


that.get('firebaseService')
          .auth()
          .createUserWithEmailAndPassword(
            ctrl.email,
            ctrl.password
          )
          .then(function(){
            that.transitionTo('/');
          })
          .catch(function(error){
            Ember.set(that.currentModel, 'flag', true);
            Ember.set(that.currentModel, 'error', error.message);
          })

Thank you for your help.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
dirkdirkcommented, Jul 5, 2017

I just solved this issue myself similarly to @tonycoco suggestion:

  createEmailUser() {
    console.log('--> createEmailUser() firing');
    let store = this.get('store');
    let userEmail = this.get('loginEmail');  // from login form
    let userPw = this.get('loginPw');          // from login form
    let timeStamp = Date.now();
    return this.get('firebaseApp').auth()
      .createUserWithEmailAndPassword(userEmail, userPw)
      .then((user) => {
        let userId  = user.uid;
        let newUser = store.createRecord('user', {
                            id: userId,
                            accountCreated: timeStamp,
                            lastLogin: timeStamp,
                            email: userEmail
                      });
        newUser.save()
                .then(() => {
                  console.log('    auth user');
                  this.get('session').open('firebase', { provider: 'password',
                                                         email: userEmail,
                                                         password: userPw })
                      .then(() => {
                        console.log('    transitionToRoute user');
                        this.transitionToRoute('user');
                      });
                 })
                .catch(error => {
                  console.log(' -- createEmailUser save error:');
                  console.log(error.message);
                });
      })
      .catch((error) => {
        console.log(' -- signIn error.message:');
        console.log(error.message);
      });
  },```
1reaction
tonycococommented, May 25, 2017

You’ll probably want something like:

createUser(email, password) {
  const route = this;
  const auth = route.get('firebaseApp').auth();

  auth.createUserWithEmailAndPassword(email, password).then((userResponse) => {
    route.get('session').open('firebase', {
      provider: 'password',
      email: email,
      password: password,
    }).then(() => {
      route.transitionTo('something-new-here'); // FIXME
    });
  }, (errorResponse) => {
    alert(errorResponse.message);
  });
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

why css transition doesn't work - Stack Overflow
I'm trying to add transition but it doesnt work I added transition to my links and expect changes on hover state I used...
Read more >
Why css transition doesn't work on newly created element?
The plan is to create a new DOM element with full height and width with transparent background and then add background-color class to...
Read more >
Can't get Assign to Current User post-function to work on the ...
You have added the "Assign to Current User" post-function to the Create Issue transition of a workflow, and it appears not to work....
Read more >
Morph transition: Tips and tricks - Microsoft Support
Learn how to use the Morph transition in PowerPoint to easily create animations and movements of objects, images, words, and characters across your ......
Read more >
Applying transitions in Premiere Pro - Adobe Support
A transition is an effect added between pieces of media to create an animated ... Changing the default transition doesn't affect transitions ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found