Run custom function after user login

Is there a way for me to run a custom function after the user successfully logs in?
I know i can have a custom redirect, like this: redirectTo: ‘/app/products’ and maybe add some value to the url like redirectTo: ‘/app/products?key=value’,
but i want to generate a token in my local client react app, after a successful login, and store the state in localstorage, the value in the state will be from

My current code:

import auth0 from "../../utils/auth0";
export default async function login(req, res){
    await auth0.handleLogin(req, res, {
      getState: (req) => {
        return {
          somevalue: 123,
          redirectTo: '/app/products'
runCustomFunctionHere() // this function should run after a successful login

    // {
    //   Authorization: `Bearer ${token}`
    // }
  } catch(error){
    console.log('error: ', error);
    res.status(error.status || 400 ).end(error.message)

or is this something i can do in callback?

My env:
NodeJS 14
React Next JS for SSR

Note sure if this is quite what you are looking for but Rules are code snippets that run after the user logs in:

1 Like

Yep you should be able to achieve what you want with Rules

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.