WaspW
Wasp15mo ago
Hastur

Can't make onAfterLogin work

Hello,

I updated wasp because I need this specific hook in my project but I really can't make it work.

Here is my app/src/auth/hooks.ts file:

import type { 
    OnAfterLoginHook 
} from 'wasp/server/auth';

export const onAfterLogin: OnAfterLoginHook = async ({
  providerId,
  user,
  oauth,
  prisma,
  req,
}) => {
  console.log('test');

  try {
    await prisma.logs.create({
      data: {
        message: 'test',
        level: 'test onAfterLogin',
      },
    });
  } catch (error) {
    console.error('Error updating Log.', error);
  }

  try {
    await prisma.user.update({
      where: {
        id: user.id,
      },
      data: {
        username: 'vdssd'
      }
    });
  } catch (error) {
    console.error('Error updating user.', error);
  }
};


Nothing appears in the console and the database is not updated.

Could you please help me?
Was this page helpful?