Skip to content

Commit 391cd29

Browse files
committed
add auto-registration in sui context...
standalone course deployments are de-facto full registration. visitors to these site are explicitly opting into interacting with the site. Differentiated from platform-ui where users select content from a broader menu
1 parent b11f589 commit 391cd29

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

packages/standalone-ui/src/main.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import * as directives from 'vuetify/directives';
1414
import { aliases, mdi } from 'vuetify/iconsets/mdi';
1515

1616
// data layer
17-
import { initializeDataLayer } from '@vue-skuilder/db';
17+
import { initializeDataLayer, getDataLayer } from '@vue-skuilder/db';
1818

1919
// auth store
2020
import { useAuthStore } from '@vue-skuilder/common-ui';
@@ -163,5 +163,28 @@ import config from '../skuilder.config.json';
163163

164164
await useAuthStore().init();
165165

166+
// Auto-register user for the course in standalone mode
167+
if (config.course) {
168+
try {
169+
const authStore = useAuthStore();
170+
const user = getDataLayer().getUserDB();
171+
172+
// Check if user is already registered for the course
173+
const courseRegistrations = await user.getCourseRegistrationsDoc();
174+
const isRegistered = courseRegistrations.courses.some(c => c.courseID === config.course);
175+
176+
if (!isRegistered) {
177+
console.log(`[Standalone] Auto-registering user for course: ${config.course}`);
178+
await user.registerForCourse(config.course, false); // non-preview mode
179+
console.log(`[Standalone] Auto-registration completed for course: ${config.course}`);
180+
} else {
181+
console.log(`[Standalone] User already registered for course: ${config.course}`);
182+
}
183+
} catch (error) {
184+
console.warn(`[Standalone] Failed to auto-register for course ${config.course}:`, error);
185+
// Don't block app startup on registration failure
186+
}
187+
}
188+
166189
app.mount('#app');
167190
})();

0 commit comments

Comments
 (0)