Skip to content

Commit c856467

Browse files
committed
fix: refactor
1 parent 7ec6a83 commit c856467

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

packages/server/src/enterprise/controllers/login-method.controller.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ import { decrypt } from '../utils/encryption.util'
1616
export class LoginMethodController {
1717
public async create(req: Request, res: Response, next: NextFunction) {
1818
try {
19+
if (
20+
getRunningExpressApp().identityManager.getPlatformType() === Platform.CLOUD ||
21+
getRunningExpressApp().identityManager.getPlatformType() === Platform.OPEN_SOURCE
22+
) {
23+
throw new InternalFlowiseError(StatusCodes.BAD_GATEWAY, GeneralErrorMessage.FORBIDDEN)
24+
}
1925
const loginMethodService = new LoginMethodService()
2026
const loginMethod = await loginMethodService.createLoginMethod(req.body)
2127
return res.status(StatusCodes.CREATED).json(loginMethod)
@@ -66,8 +72,11 @@ export class LoginMethodController {
6672
try {
6773
queryRunner = getRunningExpressApp().AppDataSource.createQueryRunner()
6874
await queryRunner.connect()
69-
if (getRunningExpressApp().identityManager.getPlatformType() === Platform.CLOUD) {
70-
throw new InternalFlowiseError(StatusCodes.BAD_REQUEST, GeneralErrorMessage.FORBIDDEN)
75+
if (
76+
getRunningExpressApp().identityManager.getPlatformType() === Platform.CLOUD ||
77+
getRunningExpressApp().identityManager.getPlatformType() === Platform.OPEN_SOURCE
78+
) {
79+
throw new InternalFlowiseError(StatusCodes.FORBIDDEN, GeneralErrorMessage.FORBIDDEN)
7180
}
7281
const query = req.query as Partial<LoginMethod>
7382
const loginMethodService = new LoginMethodService()
@@ -106,8 +115,11 @@ export class LoginMethodController {
106115
public async update(req: Request, res: Response, next: NextFunction) {
107116
try {
108117
const loginMethodService = new LoginMethodService()
109-
if (getRunningExpressApp().identityManager.getPlatformType() === Platform.CLOUD) {
110-
throw new InternalFlowiseError(StatusCodes.BAD_REQUEST, GeneralErrorMessage.FORBIDDEN)
118+
if (
119+
getRunningExpressApp().identityManager.getPlatformType() === Platform.CLOUD ||
120+
getRunningExpressApp().identityManager.getPlatformType() === Platform.OPEN_SOURCE
121+
) {
122+
throw new InternalFlowiseError(StatusCodes.FORBIDDEN, GeneralErrorMessage.FORBIDDEN)
111123
}
112124
const loginMethod = await loginMethodService.createOrUpdateConfig(req.body)
113125
if (loginMethod?.status === 'OK' && loginMethod?.organizationId) {

packages/server/src/enterprise/services/login-method.service.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ export class LoginMethodService {
7979
try {
8080
queryRunner = this.dataSource.createQueryRunner()
8181
await queryRunner.connect()
82-
if (getRunningExpressApp().identityManager.getPlatformType() === Platform.CLOUD) {
83-
throw new InternalFlowiseError(StatusCodes.BAD_REQUEST, GeneralErrorMessage.FORBIDDEN)
84-
}
8582
const createdBy = await this.userService.readUserById(data.createdBy, queryRunner)
8683
if (!createdBy) throw new InternalFlowiseError(StatusCodes.NOT_FOUND, UserErrorMessage.USER_NOT_FOUND)
8784
const organization = await this.organizationService.readOrganizationById(data.organizationId, queryRunner)

0 commit comments

Comments
 (0)