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

v4 SSO Error: Invalid hook call. Hooks can only be called inside of the body of a function component #12291

Closed
rsamms202 opened this issue Jan 25, 2022 · 6 comments
Labels
source: core:admin Source is core/admin package status: pending reproduction Waiting for free time to reproduce the issue, or more information

Comments

@rsamms202
Copy link

Bug report

Describe the bug

Upon successful SSO authentication, I get the following console error upon reaching the /admin/auth/login/success endpoint:

Error: Minified React error #321; visit https://reactjs.org/docs/error-decoder.html?invariant=321 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
    at Object.ii (main.7a31f52d.js:2:1910091)
    at t.useContext (main.7a31f52d.js:2:2081722)
    at A (main.7a31f52d.js:2:131079)
    at t.useRouteMatch (main.7a31f52d.js:2:132211)
    at m (2790.2203069c.chunk.js:1:131151)
    at 2790.2203069c.chunk.js:1:115873
    at c (main.7a31f52d.js:2:2087106)
    at Generator._invoke (main.7a31f52d.js:2:2086894)
    at Generator.next (main.7a31f52d.js:2:2087535)
    at t (main.7a31f52d.js:2:554)

Steps to reproduce the behavior

  1. Make sure that the auto registration is turned on in settings (I have set the default role to author)
  2. In ./config/admin.js set up your provider (I use passport-saml)
  3. You should see the login option in the admin panel
  4. Click on the SSO option and login via your provider
  5. When returned to Stapi you are redirected to '/admin/auth/login/success' and receive the error in the console with a spinning indicator on the website

Expected behavior

I expect that I would see login success

System

Node.js version: 16.5.0
NPM version: 7.20.3
Strapi version: 4.0.5
Database: Postgres
Operating system: MacOS

Also, if you go to: https://reactjs.org/docs/error-decoder.html/?invariant=321 you will see a list of possible reasons for this error. I have checked and do not have multiple versions of React. I checked the Strapi source code for AuthResponse/index.js and do notice hooks being used.

@derrickmehaffy
Copy link
Member

Might be related: #12328

@derrickmehaffy derrickmehaffy added status: pending reproduction Waiting for free time to reproduce the issue, or more information source: core:admin Source is core/admin package labels Jan 27, 2022
@Convly
Copy link
Member

Convly commented Jan 28, 2022

Yep, it should be fixed by #12340 which has been released in v4.0.6.

@derrickmehaffy
Copy link
Member

Setting as closed for now as I couldn't reproduce this. @rsamms202 if you hit the issue on v4.0.6 let us know and we can reopen.

@rsamms202
Copy link
Author

rsamms202 commented Jan 28, 2022

@derrickmehaffy Just tried it with 4.0.6 and am seeing the same error:Screen Shot 2022-01-28 at 1 45 50 PM

@derrickmehaffy
Copy link
Member

@derrickmehaffy Just tried it with 4.0.6 and am seeing the same error:Screen Shot 2022-01-28 at 1 45 50 PM

Can you please ensure that you delete your node modules, any lock files, reinstall your modules, and rebuild your admin.

Also who were you using the provider with?

@rsamms202
Copy link
Author

@derrickmehaffy deleting node modules, lock files and rebuilding the admin solved the issue after upgrading to version 4.0.6. Thank you for your assistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
source: core:admin Source is core/admin package status: pending reproduction Waiting for free time to reproduce the issue, or more information
Projects
None yet
Development

No branches or pull requests

3 participants