diff --git a/apps/api/src/secrets/secrets.controller.ts b/apps/api/src/secrets/secrets.controller.ts index 9f6d202..73a507a 100644 --- a/apps/api/src/secrets/secrets.controller.ts +++ b/apps/api/src/secrets/secrets.controller.ts @@ -45,9 +45,16 @@ export class SecretsController { .type('html') .type('text/html') .send( - ` Redirect succuesfully, this window should close now`, + ` + +Redirect succuesfully, this window should close now`, ); } diff --git a/apps/api/src/secrets/secrets.service.ts b/apps/api/src/secrets/secrets.service.ts index ea35159..1287bc9 100644 --- a/apps/api/src/secrets/secrets.service.ts +++ b/apps/api/src/secrets/secrets.service.ts @@ -73,10 +73,11 @@ export class SecretsService { } async claim(dto: ClaimConnectionDto) { - const { clientSecret } = await this.getSecretById(dto.clientId); + const { clientSecret, redirectUrl } = await this.getSecretById(dto.clientId); + const redirect_uri = redirectUrl ?? this.config.getOrThrow('publicUrl') + '/api/secrets/redirect' const body: Record = { - redirect_uri: this.config.getOrThrow('publicUrl') + '/api/secrets/redirect', grant_type: 'authorization_code', + redirect_uri, code: dto.code, }; diff --git a/libs/database/src/entities/secrets.entity.ts b/libs/database/src/entities/secrets.entity.ts index 1076ade..c91157b 100644 --- a/libs/database/src/entities/secrets.entity.ts +++ b/libs/database/src/entities/secrets.entity.ts @@ -19,6 +19,8 @@ export class SecretEntity extends MetaEntity { @Column({ nullable: false }) clientId: string; + @Column({ nullable: true }) + redirectUrl: string; } @CustomRepository(SecretEntity) diff --git a/libs/database/src/migrations/1705086423012-secrets-redirects.ts b/libs/database/src/migrations/1705086423012-secrets-redirects.ts new file mode 100644 index 0000000..bd91db7 --- /dev/null +++ b/libs/database/src/migrations/1705086423012-secrets-redirects.ts @@ -0,0 +1,14 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class SecretsRedirects1705086423012 implements MigrationInterface { + name = 'SecretsRedirects1705086423012' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "secret_entity" ADD "redirectUrl" character varying`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "secret_entity" DROP COLUMN "redirectUrl"`); + } + +} diff --git a/libs/database/src/migrations/index.ts b/libs/database/src/migrations/index.ts index 1e6799c..605a066 100644 --- a/libs/database/src/migrations/index.ts +++ b/libs/database/src/migrations/index.ts @@ -18,4 +18,5 @@ export * from './1697435937767-user-google'; export * from './1697737348969-email'; export * from './1697743613593-roles'; export * from './1699113772938-secrets'; -export * from './1701893634169-pieces'; \ No newline at end of file +export * from './1701893634169-pieces'; +export * from './1705086423012-secrets-redirects'; \ No newline at end of file