UNPKG

pagamio-frontend-commons-lib

Version:

Pagamio library for Frontend reusable components like the form engine and table container

27 lines (26 loc) 1.13 kB
/** * Default authenticator processor * Handles the standard authentication process with basic validation * @template T - Type extending CustomAuthConfig */ export class DefaultAuthenticatorProcessor { /** * Process login credentials using the standard authentication flow * @param credentials - User login credentials * @param rememberMe - Whether to remember the user session * @param login - The login function from auth context * @returns Promise resolving to authentication response */ async processLogin(credentials, rememberMe, login) { // Validate the credentials to ensure required fields are present if (!credentials || typeof credentials !== 'object') { throw new Error('Invalid login data: Credentials must be an object'); } const requiredKeys = Object.keys(credentials); if (requiredKeys.length === 0) { throw new Error('Invalid login data: No credentials provided'); } // Use type assertion to satisfy the login function parameter type return login(credentials, rememberMe); } }