nestjs-supabase-auth icon indicating copy to clipboard operation
nestjs-supabase-auth copied to clipboard

Supabase.js v2 Cannot read properties of undefined (reading 'getUser')

Open JernejHabjan opened this issue 2 years ago • 6 comments

[Nest] 20112  - 21/01/2023, 09:58:12   ERROR [ExceptionsHandler] Cannot read properties of undefined (reading 'getUser')
TypeError: Cannot read properties of undefined (reading 'getUser')
    at SupabaseStrategy.authenticate (...\node_modules\nestjs-supabase-auth\src\passport-supabase.strategy.ts:50:8)
    at SupabaseStrategy.authenticate (...\dist\apps\api\webpack:\...\auth\strategies\supabase.strategy.ts:26:18)
    at attempt (...\node_modules\passport\lib\middleware\authenticate.js:369:16)
    at authenticate (...\node_modules\passport\lib\middleware\authenticate.js:370:7)
    at ...\node_modules\@nestjs\passport\dist\auth.guard.js:96:3
    at new Promise (<anonymous>)
    at ...\node_modules\@nestjs\passport\dist\auth.guard.js:88:83
    at SupabaseAuthGuard.<anonymous> (...\node_modules\@nestjs\passport\dist\auth.guard.js:49:36)
    at Generator.next (<anonymous>)
    at fulfilled (...\node_modules\@nestjs\passport\dist\auth.guard.js:17:58)

The culprit is this line:

this.supabase.auth.api <<<
      .getUser(idToken)

The fix is:

this.supabase.auth <<<
      .getUser(idToken)

Currently package "nestjs-supabase-auth": "1.0.9" works with:

@supabase/supabase-js": "^1.29.4

It doesn't work for:

"@supabase/supabase-js": "^2.4.1"

JernejHabjan avatar Jan 21 '23 09:01 JernejHabjan

Will the repo be updated or will we have to fork our own since we can't do this if dockerizing

Aldo111 avatar Apr 02 '23 21:04 Aldo111

Any updates on this topic?

Pablo4Coding avatar May 18 '23 11:05 Pablo4Coding

The problem seems to be here: passport-supabase.strategy

Pablo4Coding avatar May 18 '23 11:05 Pablo4Coding

Hello everyone! Any updates on this topic? Very critical moment

Within this issue we can't create any Guard for protecting routes

alimovvadim93 avatar Jun 14 '23 09:06 alimovvadim93

Can you assign me the issue?

bhusal-rj avatar Dec 23 '23 15:12 bhusal-rj

forked and merged at https://github.com/tgirotto/nestjs-supabase-auth-v2

tgirotto avatar Feb 03 '24 15:02 tgirotto

@hiro1107 can you make another npm release? If I just run yarn add nestjs-supabase-auth - the release doesn't include this change.

christophby avatar Jul 14 '24 18:07 christophby

Simple solution for solve this problem: https://www.npmjs.com/package/patch-package use patch-package lib and replace:

node_modules/nestjs-supabase-auth/dist/passport-supabase.strategy.js

this.supabase.auth.api.getUser(idToken)

to

this.supabase.auth.getUser(idToken)

buuni avatar Jul 15 '24 21:07 buuni