refacto(*): remove everything about default workspace (#9157)
## Summary - [x] Remove defaultWorkspace in user - [x] Remove all occurrence of defaultWorkspace and defaultWorkspaceId - [x] Improve activate workspace flow - [x] Improve security on social login - [x] Add `ImpersonateGuard` - [x] Allow to use impersonation with couple `User/Workspace` - [x] Prevent unexpected reload on activate workspace - [x] Scope login token with workspaceId Fix https://github.com/twentyhq/twenty/issues/9033#event-15714863042
This commit is contained in:
@ -40,11 +40,12 @@ export class BillingResolver {
|
||||
@UseGuards(WorkspaceAuthGuard, UserAuthGuard)
|
||||
async billingPortalSession(
|
||||
@AuthUser() user: User,
|
||||
@AuthWorkspace() workspace: Workspace,
|
||||
@Args() { returnUrlPath }: BillingSessionInput,
|
||||
) {
|
||||
return {
|
||||
url: await this.billingPortalWorkspaceService.computeBillingPortalSessionURLOrThrow(
|
||||
user.defaultWorkspaceId,
|
||||
workspace.id,
|
||||
returnUrlPath,
|
||||
),
|
||||
};
|
||||
|
||||
@ -45,12 +45,13 @@ export class BillingPortalWorkspaceService {
|
||||
|
||||
const stripeCustomerId = (
|
||||
await this.billingSubscriptionRepository.findOneBy({
|
||||
workspaceId: user.defaultWorkspaceId,
|
||||
workspaceId: workspace.id,
|
||||
})
|
||||
)?.stripeCustomerId;
|
||||
|
||||
const session = await this.stripeService.createCheckoutSession(
|
||||
user,
|
||||
workspace.id,
|
||||
priceId,
|
||||
quantity,
|
||||
successUrl,
|
||||
|
||||
@ -84,6 +84,7 @@ export class StripeService {
|
||||
|
||||
async createCheckoutSession(
|
||||
user: User,
|
||||
workspaceId: string,
|
||||
priceId: string,
|
||||
quantity: number,
|
||||
successUrl?: string,
|
||||
@ -100,7 +101,7 @@ export class StripeService {
|
||||
mode: 'subscription',
|
||||
subscription_data: {
|
||||
metadata: {
|
||||
workspaceId: user.defaultWorkspaceId,
|
||||
workspaceId,
|
||||
},
|
||||
trial_period_days: this.environmentService.get(
|
||||
'BILLING_FREE_TRIAL_DURATION_IN_DAYS',
|
||||
|
||||
Reference in New Issue
Block a user