Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| devops:xhr:dev:local_dev [2025/10/22 14:55] – created td | devops: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:// | export API_HOST=http:// | ||
| ``` | ``` | ||
| - | + | ### AI agent | |
| - | ## AI agent | + | |
| platform-frontend-app/ | platform-frontend-app/ | ||
| Line 17: | Line 17: | ||
| const baseUrl = " | const baseUrl = " | ||
| 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/ | ||
| + | uv sync | ||
| + | alembic upgrade head | ||
| + | export PYTHONPATH=$(pwd) | ||
| + | uv run agent | ||
| ``` | ``` | ||
| # identitiy-management-service | # identitiy-management-service | ||
| + | ## Build option gradle | ||
| + | identity-management-service/ | ||
| + | ``` | ||
| + | gpr.user=thuydang | ||
| + | gpr.key=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 | ||
| + | ``` | ||
| - | Insert | + | ## CORS |
| + | |||
| + | ### Allow OPTIONS for CORS | ||
| + | identity-management-service/ | ||
| + | ``` | ||
| + | | ||
| + | ``` | ||
| + | |||
| + | ### Add cors headers | ||
| + | |||
| + | identity-management-service/ | ||
| + | ``` | ||
| + | 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(" | ||
| + | private String frontendBaseUrl; | ||
| + | |||
| + | @Value(" | ||
| + | private String frontendDomain; | ||
| + | |||
| + | @Override | ||
| + | public void addCorsMappings(CorsRegistry registry) { | ||
| + | registry.addMapping("/ | ||
| + | .allowedOriginPatterns( | ||
| + | frontendBaseUrl, | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | ) | ||
| + | .allowedMethods(" | ||
| + | .allowedHeaders( | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | ) | ||
| + | .allowCredentials(true) | ||
| + | .maxAge(3600); | ||
| + | } | ||
| + | } | ||
| + | ``` | ||
| + | |||
| + | |||
| + | ## Database Setup | ||
| + | |||
| + | I've successfully inserted the dummy user into the local database. Here's what was done: | ||
| + | |||
| + | |||
| + | 1. **Created a demo company**: | ||
| + | - ID: `e388a122-4a87-498f-925e-520bbf200ce3` | ||
| + | - Name: "Demo Company" | ||
| + | - Domain: " | ||
| + | |||
| + | 2. **Created the demo user**: | ||
| + | - ID: `df109bb1-e781-4b45-b4e8-f7731aec674f` | ||
| + | - Full Name: "Demo User" | ||
| + | - Email: `demo@demo.com` | ||
| + | - Password: `DemoDemo` (bcrypt hashed) | ||
| + | - Status: `ACTIVE` | ||
| + | - Group Type: `EMPLOYEE` | ||
| + | - Email Verified: `true` | ||
| + | - No password change required | ||
| + | |||
| + | ## Login Credentials | ||
| + | |||
| + | You can now login to the application using: | ||
| + | - **Email**: `demo@demo.com` | ||
| + | - **Password**: | ||
| + | |||
| + | ## Database Connection Details | ||
| + | |||
| + | - **Host**: localhost: | ||
| + | - **Database**: | ||
| + | - **Username**: | ||
| + | - **Password**: | ||
| + | |||
| + | The user is active and ready for testing the login functionality. The password has been properly hashed using bcrypt for security. | ||
| + | ### Scripts: | ||
| + | |||
| + | ``` | ||
| + | # | ||
| + | |||
| + | # Database setup script for demo user | ||
| + | # Usage: ./ | ||
| + | |||
| + | DB_HOST=" | ||
| + | DB_PORT=" | ||
| + | DB_NAME=" | ||
| + | DB_USER=" | ||
| + | DB_PASSWORD=" | ||
| + | |||
| + | # Generate UUIDs | ||
| + | COMPANY_UUID=$(python3 -c " | ||
| + | USER_UUID=$(python3 -c " | ||
| + | |||
| + | # Hash the password | ||
| + | HASHED_PASSWORD=$(python3 -c " | ||
| + | |||
| + | echo " | ||
| + | echo " | ||
| + | echo " | ||
| + | |||
| + | # Clean up existing demo data | ||
| + | echo " | ||
| + | PGPASSWORD=$DB_PASSWORD psql -h $DB_HOST -p $DB_PORT -U $DB_USER -d $DB_NAME -c " | ||
| + | DELETE FROM \" | ||
| + | DELETE FROM \" | ||
| + | DELETE FROM \" | ||
| + | " | ||
| + | |||
| + | # Insert company | ||
| + | echo " | ||
| + | PGPASSWORD=$DB_PASSWORD psql -h $DB_HOST -p $DB_PORT -U $DB_USER -d $DB_NAME -c " | ||
| + | INSERT INTO \" | ||
| + | VALUES (' | ||
| + | " | ||
| + | |||
| + | if [ $? -eq 0 ]; then | ||
| + | echo " | ||
| + | else | ||
| + | echo " | ||
| + | exit 1 | ||
| + | fi | ||
| + | |||
| + | # Insert whitelist email | ||
| + | echo " | ||
| + | PGPASSWORD=$DB_PASSWORD psql -h $DB_HOST -p $DB_PORT -U $DB_USER -d $DB_NAME -c " | ||
| + | INSERT INTO \" | ||
| + | VALUES (' | ||
| + | " | ||
| + | |||
| + | # Insert user | ||
| + | echo " | ||
| + | PGPASSWORD=$DB_PASSWORD psql -h $DB_HOST -p $DB_PORT -U $DB_USER -d $DB_NAME -c " | ||
| + | INSERT INTO \" | ||
| + | VALUES (' | ||
| + | " | ||
| + | |||
| + | if [ $? -eq 0 ]; then | ||
| + | echo "User inserted successfully." | ||
| + | echo "Demo login credentials:" | ||
| + | echo " | ||
| + | echo " | ||
| + | else | ||
| + | echo " | ||
| + | exit 1 | ||
| + | fi | ||
| + | |||
| + | echo "Demo database setup completed!" | ||
| + | ``` | ||
| + | ### Troubleshooting | ||
| + | #### Pass email form: | ||
| + | |||
| + | ``` | ||
| + | curl -X POST http:// | ||
| + | -H " | ||
| + | -d ' | ||
| + | |||
| + | ``` | ||
| + | |||
| + | #### Get Token and me | ||
| + | |||
| + | ``` | ||
| + | TOKEN=$(curl -X POST http:// | ||
| + | echo $TOKEN | ||
| + | curl http:// | ||
| + | ``` | ||
| - | ''' | ||
| - | psql -h localhost -p 5432 -U admin -d authdb -c " | ||
| - | ''' | ||