Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import { NextFunction, Request, Response } from 'express'
import { StatusCodes } from 'http-status-codes'
import { LoginMethodErrorMessage, LoginMethodService } from '../services/login-method.service'
import { InternalFlowiseError } from '../../errors/internalFlowiseError'
import { Platform } from '../../Interface'
import { GeneralErrorMessage } from '../../utils/constants'
import { getRunningExpressApp } from '../../utils/getRunningExpressApp'
import { LoginMethod, LoginMethodStatus } from '../database/entities/login-method.entity'
import { InternalFlowiseError } from '../../errors/internalFlowiseError'
import { decrypt } from '../utils/encryption.util'
import AzureSSO from '../sso/AzureSSO'
import GoogleSSO from '../sso/GoogleSSO'
import Auth0SSO from '../sso/Auth0SSO'
import { LoginMethodErrorMessage, LoginMethodService } from '../services/login-method.service'
import { OrganizationService } from '../services/organization.service'
import { Platform } from '../../Interface'
import Auth0SSO from '../sso/Auth0SSO'
import AzureSSO from '../sso/AzureSSO'
import GithubSSO from '../sso/GithubSSO'
import GoogleSSO from '../sso/GoogleSSO'
import { decrypt } from '../utils/encryption.util'

export class LoginMethodController {
public async create(req: Request, res: Response, next: NextFunction) {
Expand Down Expand Up @@ -82,13 +83,15 @@ export class LoginMethodController {
loginMethod = await loginMethodService.readLoginMethodById(query.id, queryRunner)
if (!loginMethod) throw new InternalFlowiseError(StatusCodes.NOT_FOUND, LoginMethodErrorMessage.LOGIN_METHOD_NOT_FOUND)
loginMethod.config = JSON.parse(await decrypt(loginMethod.config))
} else {
} else if (query.organizationId) {
loginMethod = await loginMethodService.readLoginMethodByOrganizationId(query.organizationId, queryRunner)

for (let method of loginMethod) {
method.config = JSON.parse(await decrypt(method.config))
}
loginMethodConfig.providers = loginMethod
} else {
throw new InternalFlowiseError(StatusCodes.BAD_REQUEST, GeneralErrorMessage.UNHANDLED_EDGE_CASE)
}
return res.status(StatusCodes.OK).json(loginMethodConfig)
} catch (error) {
Expand Down