Identity-login function not triggering on login

Hello everyone. So I’ve been trying to set up super basic identity functions to get a handle on how they work, and as far as I can tell my identity-login.js function isn’t triggering on login. The code is super simple I’m just watching the netlify dev console to see if it outputs what I intend.

exports.handler = async function(event, context) {
  const { identity, user } = context.clientContext;

  console.log(identity, user)
  return {
    statusCode: 200,
    body: JSON.stringify({
      "app_metadata": { roles: ["member"]}

When I login nothing comes up. However, when I run netlify functions:invoke on my identity-login it DOES work, and outputs: {“app_metadata”:{“roles”:[“member”]}}.
The actual ‘app-metadata’ on the netlifyIdentity.currentUser() that the frontend sees is unchanged however, still only displaying {app_metadata: {provider: “email”}}

The console.log also fires here, although it always outputs ‘undefined undefined’ no matter whether there is a logged in user or not when I run the invoke command.

I’d appreciate any guesses or tips on what I’m doing wrong, as far as I’ve been able to see in the docs I’ve done this correctly. I’m very lost haha.

My site address is
Let me know if there’s any more relevant information I can supply.

hi there, did you see this thread already? is any of this information helpful?

Just read through it, doesn’t help me unfortunately.

In that thread their identity-login seems to work but their identity-signup doesn’t, and they weren’t given any answers beyond ‘it might be a bug on our end’.

It seems like it might only not work locally with netlify dev?
I pushed and deployed my code and the console logs are outputting to the functions console in netlify, although the ‘user’ object that context is supposed to have is still coming back undefined.

Hey @bstizzle,
It’s true, local invocations of Identity functions will not work out of the box: [feature] local emulation of Netlify Identity · Issue #440 · netlify/cli · GitHub but Erez has some suggestions in this comment: [feature] local emulation of Netlify Identity · Issue #440 · netlify/cli · GitHub

As for logging client.Context, I have not been able to log context at all. Here’s what I’m seeing:

  event: 'login',
  instance_id: '52fb7f21-dc2d-4dbf-ace5-....',
  user: {
    id: '42b11801-fcee-43d1-8c03-....',
    aud: '',
    role: '',
    email: '...',
    confirmed_at: '2020-12-17T00:54:55Z',
    app_metadata: { provider: 'email' },
    user_metadata: {},
    created_at: '2020-12-17T00:54:54Z',
    updated_at: '2020-12-17T00:54:54Z'

with a function that looks like this, named identity-login.js:

exports.handler = async function(event, context) {
    return {
      statusCode: 200,

Is that payload what you’re seeing as well in the functions logging UI?

1 Like