Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this.auth.getUser() always return null #1

Open
vaimdev opened this issue Nov 2, 2018 · 0 comments
Open

this.auth.getUser() always return null #1

vaimdev opened this issue Nov 2, 2018 · 0 comments

Comments

@vaimdev
Copy link

vaimdev commented Nov 2, 2018

I am trying to use the code as a base for a similar app, however, I encounter an issue that when I use the AuthService from another Service class,

this.auth.getUser always return null

ClassRoomService class

  async create(title, text) {
    console.log(title, text);
    const user = await this.auth.getUser();

    if (user) {
      console.log(user);
      console.log(user.id);
    }
    else {
      console.log("user is null")
    }
}

I wonder what is wrong with the code, would you be kind to give me some advice ?

Forgot to mention, I add a new function for anonymousLogin in AuthService

  anonymousLogin() {

    return this.afAuth.auth.signInAnonymously()
          .then(() => console.log("successful login"))
          .catch(error => console.log(error));
  }

In component script

		this.authService.anonymousLogin().then(() => {
			 console.log("in anonymousLogin");
			this.classRoomService.create(this.act_title, this.act_text);  --> the "async create function"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant