Skip to content

Commit 9feabfd

Browse files
committed
disable device step if device management is disabled
1 parent dfca8de commit 9feabfd

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

web/src/pages/enrollment/components/EnrollmentSideBar/EnrollmentSideBar.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ export const EnrollmentSideBar = () => {
1717
const vpnOptional = useEnrollmentStore(
1818
(state) => state.enrollmentSettings?.vpn_setup_optional,
1919
);
20+
const deviceManagementDisabled = useEnrollmentStore((state) =>
21+
Boolean(
22+
state.enrollmentSettings?.admin_device_management && !state.userInfo?.is_admin,
23+
),
24+
);
2025
const [currentStep, stepsMax] = useEnrollmentStore((state) => [
2126
state.step,
2227
state.stepsMax,
@@ -48,12 +53,17 @@ export const EnrollmentSideBar = () => {
4853
stepsLL.welcome(),
4954
stepsLL.verification(),
5055
stepsLL.password(),
51-
...(!enrollmentSettings?.only_client_activation
52-
? [vpnStep, stepsLL.finish()]
53-
: [stepsLL.finish()]),
56+
...(enrollmentSettings?.only_client_activation || deviceManagementDisabled
57+
? [stepsLL.finish()]
58+
: [vpnStep, stepsLL.finish()]),
5459
];
5560
return steps;
56-
}, [LL.pages.enrollment.sideBar.steps, vpnOptional, enrollmentSettings]);
61+
}, [
62+
LL.pages.enrollment.sideBar.steps,
63+
vpnOptional,
64+
enrollmentSettings,
65+
deviceManagementDisabled,
66+
]);
5767

5868
return (
5969
<div id="enrollment-side-bar">

web/src/pages/enrollment/steps/DeviceStep/DeviceStep.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ export const DeviceStep = () => {
2424
const setStore = useEnrollmentStore((state) => state.setState);
2525
const deviceState = useEnrollmentStore((state) => state.deviceState);
2626
const settings = useEnrollmentStore((state) => state.enrollmentSettings);
27+
const deviceManagementDisabled = useEnrollmentStore((state) =>
28+
Boolean(
29+
state.enrollmentSettings?.admin_device_management && !state.userInfo?.is_admin,
30+
),
31+
);
2732
const [userPhone, userPassword] = useEnrollmentStore(
2833
(state) => [state.userInfo?.phone_number, state.userPassword],
2934
shallow,
@@ -56,7 +61,8 @@ export const DeviceStep = () => {
5661
if (
5762
(deviceState && deviceState.device && deviceState.configs) ||
5863
settings?.vpn_setup_optional ||
59-
settings?.only_client_activation
64+
settings?.only_client_activation ||
65+
deviceManagementDisabled
6066
) {
6167
setStore({
6268
loading: true,
@@ -81,11 +87,12 @@ export const DeviceStep = () => {
8187
userPassword,
8288
mutate,
8389
settings?.only_client_activation,
90+
deviceManagementDisabled,
8491
]);
8592

86-
// If only client activation is enabled, skip manual wireguard setup
93+
// If only client activation is enabled or device management by normal users is disabled, skip manual wireguard setup
8794
useEffectOnce(() => {
88-
if (settings?.only_client_activation) {
95+
if (settings?.only_client_activation || deviceManagementDisabled) {
8996
nextSubject.next();
9097
}
9198
});

0 commit comments

Comments
 (0)