feat: registration with invite codes
This commit is contained in:
@@ -28,12 +28,25 @@ const router = createRouter({
|
||||
name: 'account',
|
||||
component: () => import('../views/AccountView.vue'),
|
||||
},
|
||||
// Intentionally not linked from anywhere in the UI — reached only via an
|
||||
// invite link (see router.beforeEach below) or by typing the URL directly.
|
||||
{
|
||||
path: '/register',
|
||||
name: 'register',
|
||||
component: () => import('../views/RegisterView.vue'),
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
router.beforeEach((to) => {
|
||||
const authStore = useAuthStore()
|
||||
|
||||
// An invite link may point anywhere (e.g. the app root) so it still works
|
||||
// if the recipient doesn't have the app installed/bookmarked at /register.
|
||||
if (to.name !== 'register' && typeof to.query.invite === 'string' && to.query.invite) {
|
||||
return { name: 'register', query: { invite: to.query.invite } }
|
||||
}
|
||||
|
||||
if (to.meta.requiresAuth && !authStore.isAuthenticated) {
|
||||
return { name: 'login', query: { redirect: to.fullPath } }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user