Options
All
  • Public
  • Public/Protected
  • All
Menu

Module handlers/login

Index

Server Interfaces

Server Type aliases

Server Type aliases

GetLoginState

GetLoginState: (req: NextApiRequest, options: LoginOptions) => {}

Use this to store additional state for the user before they visit the Identity Provider to login.

// pages/api/auth/[...auth0].js
import { handleAuth, handleLogin } from '@auth0/nextjs-auth0';

const getLoginState = (req, loginOptions) => {
  return { basket_id: getBasketId(req) };
};

export default handleAuth({
  async login(req, res) {
    try {
      await handleLogin(req, res, { getLoginState });
    } catch (error) {
      res.status(error.status || 500).end(error.message);
    }
  }
});

Type declaration

    • Parameters

      Returns {}

      • [key: string]: any

HandleLogin

HandleLogin: (req: NextApiRequest, res: NextApiResponse, options?: LoginOptions) => Promise<void>

The handler for the api/auth/login route.

throws

HandlerError

Type declaration

    • (req: NextApiRequest, res: NextApiResponse, options?: LoginOptions): Promise<void>
    • Parameters

      • req: NextApiRequest
      • res: NextApiResponse
      • Optional options: LoginOptions

      Returns Promise<void>