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

Cannot read properties of null (reading 'includes') Error - After login in NuxtJs #47

Open
m7salam opened this issue Nov 10, 2021 · 3 comments

Comments

@m7salam
Copy link

m7salam commented Nov 10, 2021

Hello

I am using NuxtJs and keeps getting this weird error I tried moving in many places my code but it doesn't seem to work I'm using the persistent option to true

Everytime first time login I get this error
image

after refreshing the page it works as it should but everytime first time logging in it gives this error

I'm using the below code in default.vue layout folder

if (this.$store.state.auth.user.companies_usernames.includes('company')) {
      this.$gates.setRoles(['superuser'])
      this.$gates.setPermissions(['all'])
    } else {
      this.$store
        .dispatch(
          'user/getCurrentUser',
          this.$store.state.auth.user.company_username
        )
        .then(() => {
          this.$gates.setRoles([this.$store.state.user.currentUser.role])
          this.$gates.setPermissions(
            this.$store.state.user.currentUser.permissions
          )
        })
    }

@mreduar
Copy link

mreduar commented Mar 4, 2022

Hi @m7salam Did you manage to solve your problem?

@m7salam
Copy link
Author

m7salam commented Mar 8, 2022

Hi @m7salam Did you manage to solve your problem?

@mreduar I believe we have made a workaround but unfortunately not on the top of my head now, but didn't know what was causing it, sorry that I couldn't help

@mreduar
Copy link

mreduar commented Mar 8, 2022

I managed to solve it, the problem was that I was passing a null property. Thanks

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

2 participants