My Wiki!

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
devops:xhr:dev:local_dev [2025/10/22 15:02] – [identitiy-management-service] tddevops:xhr:dev:local_dev [2025/10/23 16:00] (current) – [Run] td
Line 3: Line 3:
  
 # Front-end # Front-end
 +
 ## .env file ## .env file
 ``` ```
Line 8: Line 9:
 export API_HOST=http://localhost:8080 --> use local backend (devlocal repo, identitiy-management-service?? as proxy) export API_HOST=http://localhost:8080 --> use local backend (devlocal repo, identitiy-management-service?? as proxy)
 ``` ```
- +### AI agent
-## AI agent+
  
 platform-frontend-app/src/shared/services/sse/SseServiceImpl.ts:54-56 platform-frontend-app/src/shared/services/sse/SseServiceImpl.ts:54-56
Line 18: Line 18:
         const url = `${baseUrl}${path}         const url = `${baseUrl}${path}
 ``` ```
 +### Run
 +
 +```
 +. .env
 +npm run dev
 +```
 +
 +### dev user
 +
 +thuy.dang+001@x-hr.co
 +1S2N
 +
 +# Start Agent
 +Change APP_PORT=8090 in .env to avoid conflict with devlocal services (identity management)
 +
 +```
 +. .venv/bin/activate
 +uv sync
 +alembic upgrade head
 +export PYTHONPATH=$(pwd)
 +uv run agent
 +```
 +
 # identitiy-management-service # identitiy-management-service
  
 +## Build option gradle
 +identity-management-service/gradle.properties:27-28
 +```
 +gpr.user=thuydang
 +gpr.key=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
 +```
  
 +## CORS
 +
 +### Allow OPTIONS for CORS
 +identity-management-service/common/src/main/java/co/xhr/identitymanagement/common/config/AuthorizationServerConfig.java:34-34
 +```
 +               .requestMatchers(org.springframework.http.HttpMethod.OPTIONS, "/**").permitAll() // A
 +```
 +
 +### Add cors headers
 +
 +identity-management-service/rest/src/main/java/co/xhr/identitymanagement/rest/configuration/WebConfiguration.java:1-54
 +```
 +package co.xhr.identitymanagement.rest.configuration;
 +
 +import org.springframework.beans.factory.annotation.Value;
 +import org.springframework.context.annotation.Configuration;
 +import org.springframework.web.servlet.config.annotation.CorsRegistry;
 +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 +
 +/**
 + * Web configuration for CORS settings
 + */
 +@Configuration
 +public class WebConfiguration implements WebMvcConfigurer {
 +
 +    @Value("${frontend.base-url:https://app.x-hr.ai}")
 +    private String frontendBaseUrl;
 +
 +    @Value("${frontend.domain:localhost}")
 +    private String frontendDomain;
 +
 +    @Override
 +    public void addCorsMappings(CorsRegistry registry) {
 +        registry.addMapping("/v*/**")
 +                .allowedOriginPatterns(
 +                        frontendBaseUrl,
 +                        "http://localhost:*",
 +                        "https://localhost:*",
 +                        "http://" + frontendDomain + ":*",
 +                        "https://" + frontendDomain + ":*",
 +                        "http://localhost:5173",
 +                        "http://localhost:3000",
 +                        "http://localhost:8080"
 +                )
 +                .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS", "PATCH")
 +                .allowedHeaders(
 +                           "Origin",
 +                           "Content-Type",
 +                           "Accept",
 +                           "Authorization",
 +                           "X-Requested-With",
 +                           "Access-Control-Request-Method",
 +                           "Access-Control-Request-Headers",
 +                           "Access-Control-Allow-Origin",
 +                           "X-Tenant-ID",
 +                           "X-Company-ID",
 +                           "X-Correlation-ID",
 +                           "x-correlation-id",
 +                           "x-session-id",
 +                           "x-tenant-id",
 +                           "x-company-id"
 +                   )
 +                .allowCredentials(true)
 +                .maxAge(3600);
 +    }
 +}
 +```
  
  
Line 57: Line 153:
  
 The user is active and ready for testing the login functionality. The password has been properly hashed using bcrypt for security. The user is active and ready for testing the login functionality. The password has been properly hashed using bcrypt for security.
- 
 ### Scripts: ### Scripts:
  
Line 82: Line 177:
 echo "Generated User UUID: $USER_UUID" echo "Generated User UUID: $USER_UUID"
 echo "Hashed Password: $HASHED_PASSWORD" echo "Hashed Password: $HASHED_PASSWORD"
 +
 +# Clean up existing demo data
 +echo "Cleaning up existing demo data..."
 +PGPASSWORD=$DB_PASSWORD psql -h $DB_HOST -p $DB_PORT -U $DB_USER -d $DB_NAME -c "
 +DELETE FROM \"public\".\"users\" WHERE email = 'demo@demo.com';
 +DELETE FROM \"public\".\"companies\" WHERE name = 'Demo Company';
 +DELETE FROM \"public\".\"whitelist_emails\" WHERE email = 'demo@demo.com';
 +"
  
 # Insert company # Insert company
Line 96: Line 199:
     exit 1     exit 1
 fi fi
 +
 +# Insert whitelist email
 +echo "Inserting demo email into whitelist..."
 +PGPASSWORD=$DB_PASSWORD psql -h $DB_HOST -p $DB_PORT -U $DB_USER -d $DB_NAME -c "
 +INSERT INTO \"public\".\"whitelist_emails\" (\"email\", \"status\", \"created_at\", \"updated_at\", \"added_by\")
 +VALUES ('demo@demo.com', 1, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, 'script');
 +"
  
 # Insert user # Insert user
Line 116: Line 226:
 echo "Demo database setup completed!" echo "Demo database setup completed!"
 ``` ```
 +### Troubleshooting
 +#### Pass email form:
 +
 +```
 +curl -X POST http://localhost:8080/v1/im/auth/express-login \
 +  -H "Content-Type: application/json" \
 +  -d '{"email": "demo@demo.com"}'
 +
 +```
 +
 +#### Get Token and me
 +
 +```
 +TOKEN=$(curl -X POST http://localhost:8080/v1/im/auth/login \\n  -H "Content-Type: application/json" \\n  -d '{"email": "demo@demo.com", "password": "DemoDemo" }' | jq -r '.data.access_token'   
 +echo $TOKEN  
 +curl http://localhost:8080/v1/im/me \\n  -H "Content-Type: application/json" \\n-H "Authorization: Bearer ${TOKEN}"  
 +```
 +

Navigation