rename core-module environment to twenty-config (#11445)
closes https://github.com/twentyhq/core-team-issues/issues/759
This commit is contained in:
@ -2,24 +2,24 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { JwtModule as NestJwtModule } from '@nestjs/jwt';
|
||||
|
||||
import { EnvironmentModule } from 'src/engine/core-modules/environment/environment.module';
|
||||
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
|
||||
import { JwtWrapperService } from 'src/engine/core-modules/jwt/services/jwt-wrapper.service';
|
||||
import { TwentyConfigModule } from 'src/engine/core-modules/twenty-config/twenty-config.module';
|
||||
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
|
||||
|
||||
const InternalJwtModule = NestJwtModule.registerAsync({
|
||||
useFactory: async (environmentService: EnvironmentService) => {
|
||||
useFactory: async (twentyConfigService: TwentyConfigService) => {
|
||||
return {
|
||||
secret: environmentService.get('APP_SECRET'),
|
||||
secret: twentyConfigService.get('APP_SECRET'),
|
||||
signOptions: {
|
||||
expiresIn: environmentService.get('ACCESS_TOKEN_EXPIRES_IN'),
|
||||
expiresIn: twentyConfigService.get('ACCESS_TOKEN_EXPIRES_IN'),
|
||||
},
|
||||
};
|
||||
},
|
||||
inject: [EnvironmentService],
|
||||
inject: [TwentyConfigService],
|
||||
});
|
||||
|
||||
@Module({
|
||||
imports: [InternalJwtModule, EnvironmentModule],
|
||||
imports: [InternalJwtModule, TwentyConfigModule],
|
||||
controllers: [],
|
||||
providers: [JwtWrapperService],
|
||||
exports: [JwtWrapperService],
|
||||
|
||||
@ -12,7 +12,7 @@ import {
|
||||
AuthException,
|
||||
AuthExceptionCode,
|
||||
} from 'src/engine/core-modules/auth/auth.exception';
|
||||
import { EnvironmentService } from 'src/engine/core-modules/environment/environment.service';
|
||||
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
|
||||
|
||||
export type WorkspaceTokenType =
|
||||
| 'ACCESS'
|
||||
@ -27,7 +27,7 @@ export type WorkspaceTokenType =
|
||||
export class JwtWrapperService {
|
||||
constructor(
|
||||
private readonly jwtService: JwtService,
|
||||
private readonly environmentService: EnvironmentService,
|
||||
private readonly twentyConfigService: TwentyConfigService,
|
||||
) {}
|
||||
|
||||
sign(payload: string | object, options?: JwtSignOptions): string {
|
||||
@ -102,7 +102,7 @@ export class JwtWrapperService {
|
||||
}
|
||||
|
||||
generateAppSecret(type: WorkspaceTokenType, workspaceId?: string): string {
|
||||
const appSecret = this.environmentService.get('APP_SECRET');
|
||||
const appSecret = this.twentyConfigService.get('APP_SECRET');
|
||||
|
||||
if (!appSecret) {
|
||||
throw new Error('APP_SECRET is not set');
|
||||
@ -114,7 +114,7 @@ export class JwtWrapperService {
|
||||
}
|
||||
|
||||
generateAppSecretLegacy(): string {
|
||||
const accessTokenSecret = this.environmentService.get(
|
||||
const accessTokenSecret = this.twentyConfigService.get(
|
||||
'ACCESS_TOKEN_SECRET',
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user