diff --git a/env/env.development b/env/env.development index 2d5995d..4fb5ad3 100644 --- a/env/env.development +++ b/env/env.development @@ -41,4 +41,6 @@ ASSETS="https://asset.sky.eigen.co.id/" GOOGLE_CALENDAR_KEY="AIzaSyCSg4P3uC9Z7kD1P4f3rf1BbBaz4Q-M55o" GOOGLE_CALENDAR_ID="326464ac296874c7121825f5ef2e2799baa90b51da240f0045aae22beec10bd5@group.calendar.google.com" -SUPERSET_URL=https://dashboard.weplayground.eigen.co.id \ No newline at end of file +SUPERSET_URL=https://dashboard.weplayground.eigen.co.id +SUPERSET_ADMIN_USERNAME=admin +SUPERSET_ADMIN_PASSWORD=admin \ No newline at end of file diff --git a/env/env.production b/env/env.production index 83683c4..5557402 100644 --- a/env/env.production +++ b/env/env.production @@ -38,4 +38,6 @@ ASSETS="https://asset.sky.eigen.co.id/" GOOGLE_CALENDAR_KEY="AIzaSyCSg4P3uC9Z7kD1P4f3rf1BbBaz4Q-M55o" GOOGLE_CALENDAR_ID="326464ac296874c7121825f5ef2e2799baa90b51da240f0045aae22beec10bd5@group.calendar.google.com" -SUPERSET_URL=https://dashboard.weplayground.eigen.co.id \ No newline at end of file +SUPERSET_URL=https://dashboard.weplayground.eigen.co.id +SUPERSET_ADMIN_USERNAME=admin +SUPERSET_ADMIN_PASSWORD=admin \ No newline at end of file diff --git a/src/modules/configuration/superset/superset.service.ts b/src/modules/configuration/superset/superset.service.ts index 556a955..4a6457d 100644 --- a/src/modules/configuration/superset/superset.service.ts +++ b/src/modules/configuration/superset/superset.service.ts @@ -4,14 +4,16 @@ import { firstValueFrom } from 'rxjs'; @Injectable() export class SupersetService { - private SUPERSET_URL = process.env.SUPERSET_URL + '/api'; + private supersetURL = process.env.SUPERSET_URL + '/api'; + private adminUsername = process.env.SUPERSET_ADMIN_USERNAME; + private adminPassword = process.env.SUPERSET_ADMIN_PASSWORD; constructor(private readonly httpService: HttpService) {} async getLoginToken() { const data = { - username: 'admin', - password: 'admin', + username: this.adminUsername, + password: this.adminPassword, provider: 'db', refresh: true, }; @@ -19,7 +21,7 @@ export class SupersetService { const response = await firstValueFrom( this.httpService.request({ method: 'POST', - url: `${this.SUPERSET_URL}/v1/security/login`, + url: `${this.supersetURL}/v1/security/login`, data: data, }), ); @@ -32,7 +34,7 @@ export class SupersetService { const response = await firstValueFrom( this.httpService.request({ method: 'GET', - url: `${this.SUPERSET_URL}/v1/security/csrf_token/`, + url: `${this.supersetURL}/v1/security/csrf_token/`, headers: { Authorization: `Bearer ${loginToken}` }, }), ); @@ -53,13 +55,13 @@ export class SupersetService { 'Content-Type': 'application/json', Authorization: `Bearer ${loginToken}`, 'X-CSRFToken': `${csrfToken}`, - Referer: `${this.SUPERSET_URL}/v1/security/guest_token/`, + Referer: `${this.supersetURL}/v1/security/guest_token/`, }; const response = await firstValueFrom( this.httpService.request({ method: 'POST', - url: `${this.SUPERSET_URL}/v1/security/guest_token/`, + url: `${this.supersetURL}/v1/security/guest_token/`, data: data, headers: headers, }),