(
app: express.Application,
email: string,
done: (err?: Error | null, user?: Express.User, info?: any) => void,
profile: passport.Profile,
accessToken: string | object,
refreshToken: string
)
| 36 | abstract initialize(): void |
| 37 | abstract refreshToken(ssoRefreshToken: string): Promise<{ [key: string]: any }> |
| 38 | async verifyAndLogin( |
| 39 | app: express.Application, |
| 40 | email: string, |
| 41 | done: (err?: Error | null, user?: Express.User, info?: any) => void, |
| 42 | profile: passport.Profile, |
| 43 | accessToken: string | object, |
| 44 | refreshToken: string |
| 45 | ) { |
| 46 | let queryRunner |
| 47 | const ssoProviderName = this.getProviderName() |
| 48 | try { |
| 49 | queryRunner = getRunningExpressApp().AppDataSource.createQueryRunner() |
| 50 | await queryRunner.connect() |
| 51 | |
| 52 | const userService = new UserService() |
| 53 | const organizationService = new OrganizationService() |
| 54 | const workspaceUserService = new WorkspaceUserService() |
| 55 | |
| 56 | let user: any = await userService.readUserByEmail(email, queryRunner) |
| 57 | let wu: any = {} |
| 58 | |
| 59 | if (!user) { |
| 60 | // In ENTERPRISE mode, we don't want to create a new user if the user is not found |
| 61 | if (getRunningExpressApp().identityManager.getPlatformType() === Platform.ENTERPRISE) { |
| 62 | throw new InternalFlowiseError(StatusCodes.NOT_FOUND, UserErrorMessage.USER_NOT_FOUND) |
| 63 | } |
| 64 | // no user found, register the user |
| 65 | const data: any = { |
| 66 | user: { |
| 67 | email: email, |
| 68 | name: profile.displayName || email, |
| 69 | status: UserStatus.ACTIVE, |
| 70 | credential: undefined |
| 71 | } |
| 72 | } |
| 73 | if (getRunningExpressApp().identityManager.getPlatformType() === Platform.CLOUD) { |
| 74 | const accountService = new AccountService() |
| 75 | const newAccount = await accountService.register(data) |
| 76 | wu = newAccount.workspaceUser |
| 77 | wu.workspace = newAccount.workspace |
| 78 | user = newAccount.user |
| 79 | } |
| 80 | } else { |
| 81 | if (user.status === UserStatus.INVITED) { |
| 82 | const data: any = { |
| 83 | user: { |
| 84 | ...user, |
| 85 | email, |
| 86 | name: profile.displayName || '', |
| 87 | status: UserStatus.ACTIVE, |
| 88 | credential: undefined |
| 89 | } |
| 90 | } |
| 91 | const accountService = new AccountService() |
| 92 | const newAccount = await accountService.register(data) |
| 93 | user = newAccount.user |
| 94 | } |
| 95 | let wsUserOrUsers = await workspaceUserService.readWorkspaceUserByLastLogin(user?.id, queryRunner) |
nothing calls this directly
no test coverage detected