From 093ecbd1a97763140e662c01c3ab9b33dec847a8 Mon Sep 17 00:00:00 2001 From: Muhsin Shah C P Date: Mon, 14 Apr 2025 13:56:06 +0530 Subject: [PATCH] [post-modularisation] [fixed] User isn't being added to the new workspace after being archived from other workspaces, when logging in from the instance. (#12557) * fixed: user isn't adding to new workspace after archived from other workspaces * fixed: password login support --- server/src/modules/auth/oauth/service.ts | 2 +- server/src/modules/auth/service.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/server/src/modules/auth/oauth/service.ts b/server/src/modules/auth/oauth/service.ts index 734380df11..79b2c41fa2 100644 --- a/server/src/modules/auth/oauth/service.ts +++ b/server/src/modules/auth/oauth/service.ts @@ -221,7 +221,7 @@ export class OauthService implements IOAuthService { if (!isInviteRedirect) { // no SSO login enabled organization available for user - creating new one const { name, slug } = generateNextNameAndSlug('My workspace'); - organizationDetails = await this.setupOrganizationsUtilService.create(name, slug, null, manager); + organizationDetails = await this.setupOrganizationsUtilService.create(name, slug, userDetails, manager); await this.userRepository.updateOne( userDetails.id, { defaultOrganizationId: organizationDetails.id }, diff --git a/server/src/modules/auth/service.ts b/server/src/modules/auth/service.ts index b67d205b5d..c555847eaa 100644 --- a/server/src/modules/auth/service.ts +++ b/server/src/modules/auth/service.ts @@ -19,6 +19,7 @@ import { UserRepository } from '../users/repository'; import { AuthUtilService } from './util.service'; import { SessionUtilService } from '../session/util.service'; import { IAuthService } from './interfaces/IService'; +import { SetupOrganizationsUtilService } from '@modules/setup-organization/util.service'; @Injectable() export class AuthService implements IAuthService { @@ -28,6 +29,7 @@ export class AuthService implements IAuthService { protected sessionUtilService: SessionUtilService, protected organizationRepository: OrganizationRepository, protected instanceSettingsUtilService: InstanceSettingsUtilService, + protected setupOrganizationsUtilService: SetupOrganizationsUtilService, protected eventEmitter: EventEmitter2 ) {} @@ -81,7 +83,7 @@ export class AuthService implements IAuthService { } else if (allowPersonalWorkspace && !isInviteRedirect) { // no form login enabled organization available for user - creating new one const { name, slug } = generateNextNameAndSlug('My workspace'); - organization = await this.organizationRepository.createOne(name, slug, manager); + organization = await this.setupOrganizationsUtilService.create(name, slug, user, manager); } else { if (!isInviteRedirect) throw new UnauthorizedException('User is not assigned to any workspaces'); }