mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-23 08:58:26 +00:00
Added SSOConfigs as Type
This commit is contained in:
parent
3652727a5b
commit
e8b755023e
1 changed files with 24 additions and 24 deletions
|
|
@ -5,13 +5,7 @@ import { GroupPermission } from 'src/entities/group_permission.entity';
|
|||
import { Organization } from 'src/entities/organization.entity';
|
||||
import { SSOConfigs } from 'src/entities/sso_config.entity';
|
||||
import { User } from 'src/entities/user.entity';
|
||||
import {
|
||||
catchDbException,
|
||||
cleanObject,
|
||||
isPlural,
|
||||
fullName,
|
||||
generateNextNameAndSlug,
|
||||
} from 'src/helpers/utils.helper';
|
||||
import { catchDbException, cleanObject, isPlural, fullName, generateNextNameAndSlug } from 'src/helpers/utils.helper';
|
||||
import { Brackets, DeepPartial, EntityManager, Repository, DataSource as TypeORMDatasource } from 'typeorm';
|
||||
import { OrganizationUser } from '../entities/organization_user.entity';
|
||||
import { EmailService } from './email.service';
|
||||
|
|
@ -265,7 +259,8 @@ export class OrganizationsService {
|
|||
});
|
||||
});
|
||||
};
|
||||
const query = this._dataSource.createQueryBuilder(OrganizationUser, 'organization_user')
|
||||
const query = this._dataSource
|
||||
.createQueryBuilder(OrganizationUser, 'organization_user')
|
||||
.innerJoinAndSelect('organization_user.user', 'user')
|
||||
.innerJoinAndSelect(
|
||||
'user.groupPermissions',
|
||||
|
|
@ -317,7 +312,8 @@ export class OrganizationsService {
|
|||
}
|
||||
|
||||
async fetchOrganizations(user: any): Promise<Organization[]> {
|
||||
return await this._dataSource.createQueryBuilder(Organization, 'organization')
|
||||
return await this._dataSource
|
||||
.createQueryBuilder(Organization, 'organization')
|
||||
.innerJoin(
|
||||
'organization.organizationUsers',
|
||||
'organization_users',
|
||||
|
|
@ -340,7 +336,8 @@ export class OrganizationsService {
|
|||
): Promise<Organization[]> {
|
||||
const statusList = status ? (typeof status === 'object' ? status : [status]) : [WORKSPACE_USER_STATUS.ACTIVE];
|
||||
|
||||
const query = this._dataSource.createQueryBuilder(Organization, 'organization')
|
||||
const query = this._dataSource
|
||||
.createQueryBuilder(Organization, 'organization')
|
||||
.innerJoin('organization.ssoConfigs', 'organization_sso', 'organization_sso.sso = :form', {
|
||||
form: 'form',
|
||||
})
|
||||
|
|
@ -374,7 +371,8 @@ export class OrganizationsService {
|
|||
}
|
||||
|
||||
async getSSOConfigs(organizationId: string, sso: string): Promise<Organization> {
|
||||
return await this._dataSource.createQueryBuilder(Organization, 'organization')
|
||||
return await this._dataSource
|
||||
.createQueryBuilder(Organization, 'organization')
|
||||
.leftJoinAndSelect('organization.ssoConfigs', 'organisation_sso', 'organisation_sso.sso = :sso', {
|
||||
sso,
|
||||
})
|
||||
|
|
@ -385,14 +383,16 @@ export class OrganizationsService {
|
|||
}
|
||||
|
||||
constructOrgFindQuery(slug: string, id: string, statusList?: Array<boolean>) {
|
||||
const query = this._dataSource.createQueryBuilder(Organization, 'organization').leftJoinAndSelect(
|
||||
'organization.ssoConfigs',
|
||||
'organisation_sso',
|
||||
'organisation_sso.enabled IN (:...statusList)',
|
||||
{
|
||||
statusList: statusList || [true, false], // Return enabled and disabled sso if status list not passed
|
||||
}
|
||||
);
|
||||
const query = this._dataSource
|
||||
.createQueryBuilder(Organization, 'organization')
|
||||
.leftJoinAndSelect(
|
||||
'organization.ssoConfigs',
|
||||
'organisation_sso',
|
||||
'organisation_sso.enabled IN (:...statusList)',
|
||||
{
|
||||
statusList: statusList || [true, false], // Return enabled and disabled sso if status list not passed
|
||||
}
|
||||
);
|
||||
if (slug) {
|
||||
query.andWhere(`organization.slug = :slug`, { slug });
|
||||
} else {
|
||||
|
|
@ -430,7 +430,7 @@ export class OrganizationsService {
|
|||
configs: {
|
||||
clientId: this.configService.get<string>('SSO_GOOGLE_OAUTH2_CLIENT_ID'),
|
||||
},
|
||||
} as any);
|
||||
} as SSOConfigs); //TODO: Need a result type for this
|
||||
}
|
||||
if (
|
||||
this.configService.get<string>('SSO_GIT_OAUTH2_CLIENT_ID') &&
|
||||
|
|
@ -451,7 +451,7 @@ export class OrganizationsService {
|
|||
),
|
||||
hostName: this.configService.get<string>('SSO_GIT_OAUTH2_HOST'),
|
||||
},
|
||||
} as any);
|
||||
} as SSOConfigs);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -846,9 +846,9 @@ export class OrganizationsService {
|
|||
}
|
||||
const result = await this.organizationsRepository.findOne({
|
||||
where: {
|
||||
...(name && { name }),
|
||||
...(slug && { slug }),
|
||||
}
|
||||
...(name && { name }),
|
||||
...(slug && { slug }),
|
||||
},
|
||||
});
|
||||
if (result) throw new ConflictException(`${name ? 'Name' : 'Slug'} must be unique`);
|
||||
return;
|
||||
|
|
|
|||
Loading…
Reference in a new issue