Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MS] Fixed error when trying to create a SaaS org with an incorrect account #9440

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions client/src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@
"alreadyExists": "This organization name is not available, please choose another one.",
"generic": "Failed to create the organization (reason: {reason}).",
"customOrderNotAuthorized": "Clients with a custom contract are not allowed to directly create organizations. If you need another organization, please make a request from your customer area.",
"notClientAccount": "Your account is not a client account.",
"incompatibleServer": "Your version of Parsec is incompatible with the server. Please update the app or contact an administrator."
},
"cancelConfirm": "Cancel organization creation",
Expand Down
1 change: 1 addition & 0 deletions client/src/locales/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@
"alreadyExists": "Ce nom d'organisation n'est pas disponible, veuillez en choisir un autre.",
"generic": "Impossible de créer l'organisation (raison: {reason}).",
"customOrderNotAuthorized": "Les clients en contrat sur mesure ne sont pas autorisés à créer une organisation directement. Si vous avez besoin d'une organisation supplémentaire, veuillez remplir une demande depuis votre espace client.",
"notClientAccount": "Votre compte n'est pas un compte client.",
"incompatibleServer": "Votre version de Parsec n'est pas compatible avec le serveur. Veuillez mettre à jour votre application ou contacter un administrateur."
},
"cancelConfirm": "Annulation",
Expand Down
14 changes: 7 additions & 7 deletions client/src/services/bms/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ async function getPersonalInformation(token: AuthenticationToken): Promise<BmsRe
id: axiosResponse.data.id,
createdAt: DateTime.fromISO(axiosResponse.data.created_at),
email: axiosResponse.data.email,
firstName: axiosResponse.data.client.firstname,
lastName: axiosResponse.data.client.lastname,
clientId: axiosResponse.data.client.id,
phone: axiosResponse.data.client.phone || undefined,
job: axiosResponse.data.client.job || undefined,
company: axiosResponse.data.client.company || undefined,
billingSystem: (axiosResponse.data.client.billing_system as BillingSystem) ?? BillingSystem.None,
firstName: axiosResponse.data.client ? axiosResponse.data.client.firstname : '',
lastName: axiosResponse.data.client ? axiosResponse.data.client.lastname : '',
clientId: axiosResponse.data.client ? axiosResponse.data.client.id : '',
phone: axiosResponse.data.client ? axiosResponse.data.client.phone : undefined,
job: axiosResponse.data.client ? axiosResponse.data.client.job : undefined,
company: axiosResponse.data.client ? axiosResponse.data.client.company : undefined,
billingSystem: axiosResponse.data.client ? (axiosResponse.data.client.billing_system as BillingSystem) : BillingSystem.None,
},
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,18 @@ onMounted(async () => {

async function onLoginSuccess(_token: AuthenticationToken, info: PersonalInformationResultData): Promise<void> {
if (
(info.billingSystem === BillingSystem.CustomOrder || info.billingSystem === BillingSystem.ExperimentalCandidate) &&
(info.billingSystem === BillingSystem.CustomOrder ||
info.billingSystem === BillingSystem.ExperimentalCandidate ||
info.billingSystem === BillingSystem.None) &&
!props.bootstrapLink
) {
emits('closeRequested', true);
props.informationManager.present(
new Information({
message: 'CreateOrganization.errors.customOrderNotAuthorized',
message:
info.billingSystem === BillingSystem.None
? 'CreateOrganization.errors.notClientAccount'
: 'CreateOrganization.errors.customOrderNotAuthorized',
level: InformationLevel.Error,
}),
PresentationMode.Modal,
Expand Down
24 changes: 15 additions & 9 deletions client/tests/e2e/helpers/bms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,26 +100,32 @@ async function mockLogin(page: Page, options?: MockRouteOptions): Promise<void>

interface MockUserOverload {
billingSystem?: 'STRIPE' | 'CUSTOM_ORDER' | 'NONE' | 'EXPERIMENTAL_CANDIDATE';
noClient?: boolean;
}

async function mockUserRoute(page: Page, overload: MockUserOverload = {}, options?: MockRouteOptions): Promise<void> {
await mockRoute(page, `**/users/${DEFAULT_USER_INFORMATION.id}`, options, async (route) => {
if (route.request().method() === 'GET') {
let client = null;
if (!overload.noClient) {
client = {
firstname: UserData.firstName,
lastname: UserData.lastName,
id: '1337',
job: UserData.job,
company: UserData.company,
phone: UserData.phone,
billing_system: overload.billingSystem ?? 'STRIPE',
};
}

await route.fulfill({
status: 200,
json: {
id: DEFAULT_USER_INFORMATION.id,
created_at: '2024-07-15T13:21:32.141317Z',
email: UserData.email,
client: {
firstname: UserData.firstName,
lastname: UserData.lastName,
id: '1337',
job: UserData.job,
company: UserData.company,
phone: UserData.phone,
billing_system: overload.billingSystem ?? 'STRIPE',
},
client: client,
},
});
} else if (route.request().method() === 'PATCH') {
Expand Down
14 changes: 14 additions & 0 deletions client/tests/e2e/specs/create_organization_saas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,3 +448,17 @@ msTest('Try to create an org with custom order', async ({ home }) => {
'Error',
);
});

msTest('Try to create an org without being a client', async ({ home }) => {
const modal = await openCreateOrganizationModal(home);

await MockBms.mockLogin(home);
await MockBms.mockUserRoute(home, { noClient: true });

const bmsContainer = modal.locator('.saas-login');
await fillIonInput(bmsContainer.locator('ion-input').nth(0), DEFAULT_USER_INFORMATION.email);
await fillIonInput(bmsContainer.locator('ion-input').nth(1), DEFAULT_USER_INFORMATION.password);
await bmsContainer.locator('.saas-login-button').locator('.saas-login-button__item').nth(1).click();
await expect(modal).toBeHidden();
await expect(home).toShowInformationModal('Your account is not a client account.', 'Error');
});
Loading