dappsnation / akita-ng-fire

Akita ❤️ Angular 🔥 Firebase
MIT License
131 stars 27 forks source link

Issue 144 #147

Closed fritzschoff closed 4 years ago

fritzschoff commented 4 years ago

resolves #144

fritzschoff commented 4 years ago

@jgrossrieder you were right with the createProfile function that it should only be called when it is a new user. Did some changes, have a look

jaytonic commented 4 years ago

@jgrossrieder you were right with the createProfile function that it should only be called when it is a new user. Did some changes, have a look

Awesome thank you! One question though: Where do we check if the login was successfull? I mean, if the user did enter some wrong credentials, I guess that you do not need to retrieve current profile?

hakimio commented 4 years ago

@jgrossrieder Sth like the following should work.

    async login() {
        const formValue = this.loginForm.value,
            email = formValue.email,
            password = formValue.password;

        try {
            await this.authService.signin(email, password);
        } catch (e) {
            this.dialog.open(this.failedLoginDialog, {
                data: {
                    message: e.message
                }
            });
        }
    }
jaytonic commented 4 years ago

@hakimio Okay my bad, I didn't know an exception was thrown. Perfect then.

hakimio commented 4 years ago

@fritzschoff this PR causes TypeError: Cannot assign to read only property 'profile' of object when creating new user. You can not do the following:

this.store.update(state => state.profile = profile);

it should be:

this.store.update(state => ({profile}));

but, to be honest, I don't understand what's wrong with just this.store.update({profile});?

fritzschoff commented 4 years ago

his.store.update({profile}) that is causing a type error. Will check with your suggestion

hakimio commented 4 years ago

Just type-cast? this.store.update(<WhateverTypeItShouldBe>{profile});