-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathusers.router.js
More file actions
91 lines (88 loc) · 2.89 KB
/
users.router.js
File metadata and controls
91 lines (88 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**
* Module dependencies.
*/
import user from '../views/user.view.vue';
// TODO(remove one release after PR(c) merges AND after billing.store successUrl repointed):
// legacy ?tab=subscriptions alias — one-release retention only.
// IMPORTANT: this guard also actively bridges Stripe successUrl redirects —
// billing.store.js createCheckout/createExtrasCheckout currently point successUrl
// to `/users?tab=subscriptions&success=true`. Do NOT remove this guard until those
// successUrl values are repointed to `/users/billing?success=true`.
/**
* @desc Redirect legacy `/users?tab=subscriptions` bookmarks to the canonical
* account billing route `/users/billing`. Preserves all other query params
* and drops only the `tab` key (Vue Router silently drops undefined-valued
* query keys from the final URL). Returns `undefined` for all other traffic
* so the /users profile view renders normally.
*
* Note: if `to.query.tab` is an array (repeated `?tab=` param), the strict
* `=== 'subscriptions'` does NOT redirect — conservative pass-through for
* ambiguous input, by design.
* @param {import('vue-router').RouteLocationNormalized} to - Incoming route.
* @returns {{ path: string, query: Object } | undefined}
*/
const redirectLegacySubscriptionsTab = (to) => {
if (to.query?.tab === 'subscriptions') {
return { path: '/users/billing', query: { ...to.query, tab: undefined } };
}
};
/**
* Router configuration.
*/
export default [
{
path: '/users',
name: 'Account',
component: user,
// TODO(remove one release after PR(c) merges AND after billing.store successUrl repointed):
// drop beforeEnter once ?tab=subscriptions bookmarks expire AND billing.store.js
// createCheckout/createExtrasCheckout successUrl values are repointed to /users/billing.
beforeEnter: redirectLegacySubscriptionsTab,
meta: {
icon: 'fa-solid fa-circle-user',
order: 10, // sidenav sort order within bottom section (lower = first)
position: 'bottom',
requiresAuth: true,
action: 'read',
subject: 'User',
},
children: [
{
// bare /users → /users/profile (default child)
path: '',
redirect: { name: 'Account Profile' },
},
{
path: 'profile',
name: 'Account Profile',
component: () => import('../views/user.profile.view.vue'),
meta: {
display: false,
action: 'read',
subject: 'User',
},
},
{
path: 'organizations',
name: 'Account Organizations',
component: () => import('../views/user.organizations.view.vue'),
meta: {
display: false,
action: 'read',
subject: 'User',
},
},
],
},
{
path: '/users/:id',
redirect: '/users',
meta: {
display: false,
requiresAuth: true,
},
},
];
/**
* Exports.
*/