GithubHelp home page GithubHelp logo

Comments (2)

NooBiToo avatar NooBiToo commented on May 28, 2024

Hi, I have a project with Auth0 as an auth provider. The redirect/callback works fine, the jwt is added as a cookie and everything. On the Login page, I can display the $strapi.user info.

The problem happens when I need to use the middleware:
I have two middlwwares:

  • One to tell me when the user is logged in, to show some secret pages (auth.js)
  • Another to tell me when the user is not logged, to redirect to login (authenticated.js)

image

I'm doing this because I have some public pages, like forgot-password and register, for example, that I don't want that someone that is already logged in can see.

The problem is:
After I pass the login flow, starts a war between that two middleware:
image

I know that the $strapi exists (and is not null) because I can see all the info on the login page. But what's happening with one telling me that the $strapi exists and another telling me otherwise?

Just to understand: the local (username/password) flow works flawlessly.

but you have to use $strapi.user

export default function ({ redirect, $strapi }) {
  if (!$strapi.user) {
    return redirect("/login");
  }
}

from strapi.

benjamincanac avatar benjamincanac commented on May 28, 2024

Closing this as there was no answer from author and @NooBiToo solution seems to be right.

from strapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.