or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-3/

User Profile Manager

Build a user authentication system that integrates Google OAuth 2.0 authentication and manages user profile data efficiently.

Requirements

Your system should:

  1. Implement Google OAuth 2.0 authentication flow with a callback route
  2. Extract and store only the essential user profile fields: user ID, display name, and primary email address
  3. Handle cases where profile fields might be missing or unavailable
  4. Store the user profile data in an in-memory data structure (use a Map or plain object)
  5. Provide a route to retrieve stored user profiles

Capabilities

Authentication Flow

  • Initiates Google OAuth 2.0 authentication with appropriate scopes @test
  • Handles the OAuth callback and extracts user profile data @test

Profile Data Extraction

  • Extracts user ID from the profile object @test
  • Extracts display name from the profile object @test
  • Extracts primary email address from the profile object @test
  • Handles missing email addresses gracefully by storing null @test
  • Handles missing display name gracefully by storing null @test

User Storage

  • Stores user profile with only ID, display name, and email in memory @test
  • Retrieves stored user profile by user ID @test

Implementation

@generates

API

/**
 * Configures and initializes the Google OAuth 2.0 authentication strategy
 * @param {Object} config - Configuration object
 * @param {string} config.clientID - Google OAuth client ID
 * @param {string} config.clientSecret - Google OAuth client secret
 * @param {string} config.callbackURL - Callback URL for OAuth flow
 * @returns {void}
 */
function configureAuth(config) {
  // Implementation
}

/**
 * Extracts essential profile fields from Google profile object
 * @param {Object} profile - Google user profile object
 * @returns {Object} Object with id, displayName, and email fields
 */
function extractProfileData(profile) {
  // Implementation
}

/**
 * Stores user profile data in memory
 * @param {Object} profileData - User profile data with id, displayName, and email
 * @returns {void}
 */
function storeUserProfile(profileData) {
  // Implementation
}

/**
 * Retrieves stored user profile by user ID
 * @param {string} userId - Google user ID
 * @returns {Object|null} User profile data or null if not found
 */
function getUserProfile(userId) {
  // Implementation
}

module.exports = {
  configureAuth,
  extractProfileData,
  storeUserProfile,
  getUserProfile
};

Dependencies { .dependencies }

passport { .dependency }

Provides authentication middleware for Node.js applications.

passport-google-oauth { .dependency }

Provides Google OAuth authentication strategies for Passport.