Home
Support Forums

Identity not working (at all)

What the title says. Can’t make it work.

Here’s my code:

exports.handler = function (event, context, callback) {
    const data = JSON.parse(event.body);
    const { user } = data;

    const responseBody = { 
        app_metadata: {
            roles: ['member'],
            my_user_info: 'user info'
        }
    };
    callback(null, {
        statusCode: 200,
        body: JSON.stringify(responseBody)
    });
}; 

My site is very simple, but can’t show it (sadly).

/index.html
/access.html
/protected/index.html

The access.html works as a 404 and a 403 page, to simplify things.

I’m trying to access the protected area from both, index and access. So far, it doesn’t works.

my _redirects is very simple

# Role-based redirects do not have a “to” property.

/protected/*	200!	Role=member

It appears to login, but when I try to go to my protected area, it keeps redirecting back to /access.html

Here is my html code

<script type="text/javascript" src="https://identity.netlify.com/v1/netlify-identity-widget.js"></script>
<div data-netlify-identity-menu id="identity" class="text-center"></div>

That’'s it. That’s all I have.

Expected result? It should work.
Current result: it throws me a 404 error page. “Not found”.

And when I look at my local storage, I see the roles are empty!

image

I have literally read every article on the first ten google results and there is nothing that can tell me what I’m doing wrong. It should work out of the box, but it just doesn’t.

I’m using lambda functions and node, not react, vue, etc.

Any help will be greatly appreciated.

Can you make a cut-down version of your site (without information, etc.) in a new git repository and deploy it?

I was able to reproduce the whole site.

This is the site:

heuristic-kalam-d2a8e4.netlify.app

And here is the github:

It works when it is published online, but when I try to run the site in a local environment (Netlify Dev CLI) the protected page cannot be found.

Fire the Netlify Dev CLI under localhost:8888 and try this:

  1. Click the login button
  2. Enter https://heuristic-kalam-d2a8e4.netlify.app under the Development Settings of the login box
  3. Login with usr: test@test.compass: test
  4. Click the “Go to protected area”
  5. Watch it fail

Hi @MrAllanQuatermain,

This might help: