Authentication

To perform authentication, a user-defined asynchronus authentication function should be passed to the defineMMIAuthenticator function in the API route server/api/mmi/auth.ts. The function should return an asyncronous promise of the type MMI_Authenticator_response

import { defineMMIAuthenticator } from "#mmi/server/utils/authenticator"
import type { MMI_Authenticator_Response } from "#mmi/types";

export default defineMMIAuthenticator({
    authenticate: async (username: string, password: string): Promise<MMI_Authenticator_Response> => {

  //your authentication functions here

  if(authenticated) {
    return {
        success: true,
        user: {
            username: "theUsername",
            firstName: "UsersFirstName",
            lastName: "UsersLastName",
            roles: ['superUser','regularUser']
        },
        secureSessionData: {
            favoriteColor: "blue"
        }
    }
  } else {
    return {
      success: false
    }
  }
    
})

In the module, this will create a session with the provided information, store it in Redis with an expiration time equal to that of the session expiration, and return the authentication information to the signIn() function on the front end along with a signed JWT in a cookie.

Login Functions

Documentation in progress