Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagoevanp committed Oct 16, 2023
1 parent 062e6a8 commit 16cf6df
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions apps/meteor/client/startup/setupWizard.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';

import { hasPermission, hasRole } from '../../app/authorization/client';
import { hasRole } from '../../app/authorization/client';
import { settings } from '../../app/settings/client';
import { sdk } from '../../app/utils/client/lib/SDKClient';
// import { sdk } from '../../app/utils/client/lib/SDKClient';
import { router } from '../providers/RouterProvider';

Meteor.startup(async () => {
const { registrationStatus } = await sdk.rest.get('/v1/cloud.registrationStatus');
Meteor.startup(
/* async*/ () => {
// const { registrationStatus } = await sdk.rest.get('/v1/cloud.registrationStatus');

Tracker.autorun(() => {
const setupWizardState = settings.get('Show_Setup_Wizard');
Tracker.autorun(() => {
const setupWizardState = settings.get('Show_Setup_Wizard');

const hasRegisterCloudPermission = hasPermission('register-on-cloud');
const userId = Meteor.userId();
// const hasRegisterCloudPermission = hasPermission('register-on-cloud');
const userId = Meteor.userId();

const isAdmin = userId && hasRole(userId, 'admin');
const isAdmin = userId && hasRole(userId, 'admin');

const isWizardInProgress = isAdmin && setupWizardState === 'in_progress';
const isWizardInProgress = isAdmin && setupWizardState === 'in_progress';

const isWorkspaceRegistered = registrationStatus?.workspaceRegistered;
// const isWorkspaceRegistered = registrationStatus?.workspaceRegistered;

const mustRedirect =
(!userId && setupWizardState === 'pending') || isWizardInProgress || (!isWorkspaceRegistered && hasRegisterCloudPermission);
const mustRedirect =
(!userId && setupWizardState === 'pending') || isWizardInProgress; /* || (!isWorkspaceRegistered && hasRegisterCloudPermission)*/

if (mustRedirect) {
router.navigate('/setup-wizard');
}
});
});
if (mustRedirect) {
router.navigate('/setup-wizard');
}
});
},
);

0 comments on commit 16cf6df

Please sign in to comment.