Skip to content

Commit b2a70fb

Browse files
authored
use reg-guard for general signup guard (#945)
2 parents 7b5c486 + c020a5c commit b2a70fb

File tree

3 files changed

+34
-13
lines changed

3 files changed

+34
-13
lines changed

packages/platform-ui/src/App.vue

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<v-app-bar-nav-icon @click.stop="toggleDrawer"></v-app-bar-nav-icon>
4646
</SkMouseTrapToolTip>
4747
<v-spacer></v-spacer>
48-
<user-login-and-registration-container :show-registration="shouldShowRegistration()" />
48+
<user-login-and-registration-container :show-registration="isRegistrationEnabled()" />
4949
</v-app-bar>
5050

5151
<v-main>
@@ -89,6 +89,7 @@ import {
8989
useConfigStore,
9090
useAuthStore,
9191
} from '@vue-skuilder/common-ui';
92+
import { isRegistrationEnabled } from './utils/registrationGuard';
9293
9394
defineOptions({
9495
name: 'App',
@@ -104,10 +105,6 @@ const rail = ref(false);
104105
105106
const ready = ref(false);
106107
107-
const shouldShowRegistration = () => {
108-
return !window.location.href.includes('eduquilt.com');
109-
};
110-
111108
const toggleDrawer = () => {
112109
drawer.value = !drawer.value;
113110
// Optional: reset rail when drawer is toggled

packages/platform-ui/src/router.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { MarkdownRenderer, getCurrentUser } from '@vue-skuilder/common-ui';
22
import { useAuthRedirectStore } from './stores/useAuthRedirectStore';
3+
import { isRegistrationEnabled } from './utils/registrationGuard';
34
import { createRouter, createWebHistory } from 'vue-router';
45
import ClassroomCtrlPanel from './components/Classrooms/ClassroomCtrlPanel.vue';
56
import JoinCode from './components/Classrooms/JoinCode.vue';
@@ -18,7 +19,7 @@ import ReleaseNotes from './views/ReleaseNotes.vue';
1819
import VerifyEmailView from './views/VerifyEmail.vue';
1920
import RequestPasswordResetView from './views/RequestPasswordReset.vue';
2021
import ResetPasswordView from './views/ResetPassword.vue';
21-
// import SignUp from './views/SignUp.vue';
22+
import SignUp from './views/SignUp.vue';
2223
import Study from './views/Study.vue';
2324
import User from './views/User.vue';
2425
import DataInputFormTester from './dev/DataInputFormTester.vue';
@@ -64,13 +65,16 @@ const router = createRouter({
6465
name: 'login',
6566
component: Login,
6667
},
67-
// Suppress signup for now
68-
//
69-
// {
70-
// path: '/signup',
71-
// name: 'signup',
72-
// component: SignUp,
73-
// },
68+
{
69+
path: '/signup',
70+
name: 'signup',
71+
component: SignUp,
72+
beforeEnter: () => {
73+
if (!isRegistrationEnabled()) {
74+
return { name: 'home' };
75+
}
76+
},
77+
},
7478
{
7579
path: '/verify',
7680
name: 'verify',
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Centralized utility for checking if user registration is enabled.
3+
* Registration is disabled for the production deployment at eduquilt.com
4+
* to restrict access to testing/family use only.
5+
*/
6+
7+
const REGISTRATION_DISABLED_HOSTS = new Set([
8+
'eduquilt.com',
9+
'www.eduquilt.com',
10+
]);
11+
12+
export function isRegistrationEnabled(): boolean {
13+
try {
14+
const url = new URL(window.location.href);
15+
return !REGISTRATION_DISABLED_HOSTS.has(url.hostname);
16+
} catch {
17+
// If URL parsing fails, default to allowing registration (safer fallback)
18+
return true;
19+
}
20+
}

0 commit comments

Comments
 (0)