2016-09-18 19:51:20 +00:00
|
|
|
import Vue from 'vue';
|
|
|
|
|
import VueRouter from 'vue-router';
|
2017-06-29 18:49:05 +00:00
|
|
|
import getStore from 'client/store';
|
2017-09-08 19:23:58 +00:00
|
|
|
import * as Analytics from 'client/libs/analytics';
|
2017-01-17 18:45:27 +00:00
|
|
|
|
2017-07-29 22:08:36 +00:00
|
|
|
// import EmptyView from './components/emptyView';
|
2017-06-09 01:24:40 +00:00
|
|
|
|
2017-01-17 18:45:27 +00:00
|
|
|
// TODO Dummy elements used as placeholder until real components are implemented
|
2016-11-18 18:20:25 +00:00
|
|
|
import ParentPage from './components/parentPage';
|
2016-09-18 19:51:20 +00:00
|
|
|
|
2017-06-28 03:53:59 +00:00
|
|
|
// Static Pages
|
2017-10-04 02:15:00 +00:00
|
|
|
const StaticWrapper = () => import(/* webpackChunkName: "entry" */'./components/static/staticWrapper');
|
|
|
|
|
const HomePage = () => import(/* webpackChunkName: "entry" */'./components/static/home');
|
|
|
|
|
|
2017-07-20 18:20:53 +00:00
|
|
|
const AppPage = () => import(/* webpackChunkName: "static" */'./components/static/app');
|
|
|
|
|
const ClearBrowserDataPage = () => import(/* webpackChunkName: "static" */'./components/static/clearBrowserData');
|
|
|
|
|
const CommunityGuidelinesPage = () => import(/* webpackChunkName: "static" */'./components/static/communityGuidelines');
|
|
|
|
|
const ContactPage = () => import(/* webpackChunkName: "static" */'./components/static/contact');
|
|
|
|
|
const FAQPage = () => import(/* webpackChunkName: "static" */'./components/static/faq');
|
|
|
|
|
const FeaturesPage = () => import(/* webpackChunkName: "static" */'./components/static/features');
|
|
|
|
|
const GroupPlansPage = () => import(/* webpackChunkName: "static" */'./components/static/groupPlans');
|
|
|
|
|
const MerchPage = () => import(/* webpackChunkName: "static" */'./components/static/merch');
|
2017-09-30 15:48:24 +00:00
|
|
|
const NewsPage = () => import(/* webpackChunkName: "static" */'./components/static/newStuff');
|
2017-07-20 18:20:53 +00:00
|
|
|
const OverviewPage = () => import(/* webpackChunkName: "static" */'./components/static/overview');
|
|
|
|
|
const PressKitPage = () => import(/* webpackChunkName: "static" */'./components/static/pressKit');
|
|
|
|
|
const PrivacyPage = () => import(/* webpackChunkName: "static" */'./components/static/privacy');
|
|
|
|
|
const TermsPage = () => import(/* webpackChunkName: "static" */'./components/static/terms');
|
|
|
|
|
|
2017-09-27 16:57:52 +00:00
|
|
|
const RegisterLoginReset = () => import(/* webpackChunkName: "auth" */'./components/auth/registerLoginReset');
|
2016-12-29 19:24:08 +00:00
|
|
|
|
2017-07-18 04:18:17 +00:00
|
|
|
// User Pages
|
2017-07-31 19:54:52 +00:00
|
|
|
// const StatsPage = () => import(/* webpackChunkName: "user" */'./components/userMenu/stats');
|
|
|
|
|
// const AchievementsPage = () => import(/* webpackChunkName: "user" */'./components/userMenu/achievements');
|
2017-08-01 18:52:49 +00:00
|
|
|
const ProfilePage = () => import(/* webpackChunkName: "user" */'./components/userMenu/profilePage');
|
2017-07-04 18:11:08 +00:00
|
|
|
|
2017-07-20 18:01:00 +00:00
|
|
|
// Settings
|
|
|
|
|
const Settings = () => import(/* webpackChunkName: "settings" */'./components/settings/index');
|
|
|
|
|
const API = () => import(/* webpackChunkName: "settings" */'./components/settings/api');
|
|
|
|
|
const DataExport = () => import(/* webpackChunkName: "settings" */'./components/settings/dataExport');
|
|
|
|
|
const Notifications = () => import(/* webpackChunkName: "settings" */'./components/settings/notifications');
|
|
|
|
|
const PromoCode = () => import(/* webpackChunkName: "settings" */'./components/settings/promoCode');
|
|
|
|
|
const Site = () => import(/* webpackChunkName: "settings" */'./components/settings/site');
|
|
|
|
|
const Subscription = () => import(/* webpackChunkName: "settings" */'./components/settings/subscription');
|
|
|
|
|
|
2017-07-25 14:24:40 +00:00
|
|
|
// Hall
|
|
|
|
|
const HallPage = () => import(/* webpackChunkName: "hall" */'./components/hall/index');
|
|
|
|
|
const PatronsPage = () => import(/* webpackChunkName: "hall" */'./components/hall/patrons');
|
|
|
|
|
const HeroesPage = () => import(/* webpackChunkName: "hall" */'./components/hall/heroes');
|
|
|
|
|
|
2017-07-04 18:11:08 +00:00
|
|
|
// Except for tasks that are always loaded all the other main level
|
2017-06-26 21:55:14 +00:00
|
|
|
// All the main level
|
2017-06-08 19:04:19 +00:00
|
|
|
// components are loaded in separate webpack chunks.
|
|
|
|
|
// See https://webpack.js.org/guides/code-splitting-async/
|
|
|
|
|
// for docs
|
|
|
|
|
|
2017-06-26 21:55:14 +00:00
|
|
|
// Tasks
|
|
|
|
|
const UserTasks = () => import(/* webpackChunkName: "userTasks" */'./components/tasks/user');
|
|
|
|
|
|
2017-01-17 18:45:27 +00:00
|
|
|
// Inventory
|
2017-06-08 19:04:19 +00:00
|
|
|
const InventoryContainer = () => import(/* webpackChunkName: "inventory" */'./components/inventory/index');
|
|
|
|
|
const ItemsPage = () => import(/* webpackChunkName: "inventory" */'./components/inventory/items/index');
|
|
|
|
|
const EquipmentPage = () => import(/* webpackChunkName: "inventory" */'./components/inventory/equipment/index');
|
2017-06-23 11:24:10 +00:00
|
|
|
const StablePage = () => import(/* webpackChunkName: "inventory" */'./components/inventory/stable/index');
|
2017-01-17 18:45:27 +00:00
|
|
|
|
2017-06-02 20:55:02 +00:00
|
|
|
// Guilds
|
2017-07-25 14:24:40 +00:00
|
|
|
const GuildIndex = () => import(/* webpackChunkName: "guilds" */ './components/groups/index');
|
|
|
|
|
const TavernPage = () => import(/* webpackChunkName: "guilds" */ './components/groups/tavern');
|
|
|
|
|
const MyGuilds = () => import(/* webpackChunkName: "guilds" */ './components/groups/myGuilds');
|
|
|
|
|
const GuildsDiscoveryPage = () => import(/* webpackChunkName: "guilds" */ './components/groups/discovery');
|
2017-08-20 22:49:47 +00:00
|
|
|
const GroupPage = () => import(/* webpackChunkName: "guilds" */ './components/groups/group');
|
2017-07-25 14:24:40 +00:00
|
|
|
const GroupPlansAppPage = () => import(/* webpackChunkName: "guilds" */ './components/groups/groupPlan');
|
2016-12-29 19:24:08 +00:00
|
|
|
|
2017-08-14 19:19:41 +00:00
|
|
|
// Group Plans
|
|
|
|
|
const GroupPlanIndex = () => import(/* webpackChunkName: "group-plans" */ './components/group-plans/index');
|
|
|
|
|
const GroupPlanTaskInformation = () => import(/* webpackChunkName: "group-plans" */ './components/group-plans/taskInformation');
|
2017-10-04 23:26:05 +00:00
|
|
|
const GroupPlanBilling = () => import(/* webpackChunkName: "group-plans" */ './components/group-plans/billing');
|
2017-08-14 19:19:41 +00:00
|
|
|
|
2017-07-20 20:52:46 +00:00
|
|
|
// Challenges
|
|
|
|
|
const ChallengeIndex = () => import(/* webpackChunkName: "challenges" */ './components/challenges/index');
|
|
|
|
|
const MyChallenges = () => import(/* webpackChunkName: "challenges" */ './components/challenges/myChallenges');
|
|
|
|
|
const FindChallenges = () => import(/* webpackChunkName: "challenges" */ './components/challenges/findChallenges');
|
|
|
|
|
const ChallengeDetail = () => import(/* webpackChunkName: "challenges" */ './components/challenges/challengeDetail');
|
|
|
|
|
|
2017-07-27 17:41:23 +00:00
|
|
|
// Shops
|
|
|
|
|
const ShopsContainer = () => import(/* webpackChunkName: "shops" */'./components/shops/index');
|
|
|
|
|
const MarketPage = () => import(/* webpackChunkName: "shops-market" */'./components/shops/market/index');
|
2017-07-31 23:04:40 +00:00
|
|
|
const QuestsPage = () => import(/* webpackChunkName: "shops-quest" */'./components/shops/quests/index');
|
|
|
|
|
const SeasonalPage = () => import(/* webpackChunkName: "shops-seasonal" */'./components/shops/seasonal/index');
|
|
|
|
|
const TimeTravelersPage = () => import(/* webpackChunkName: "shops-timetravelers" */'./components/shops/timeTravelers/index');
|
2017-07-27 17:41:23 +00:00
|
|
|
|
2017-09-28 17:19:15 +00:00
|
|
|
import NotFoundPage from './components/404';
|
|
|
|
|
|
2016-09-18 19:51:20 +00:00
|
|
|
Vue.use(VueRouter);
|
|
|
|
|
|
2017-06-29 18:49:05 +00:00
|
|
|
const router = new VueRouter({
|
2016-09-18 19:51:20 +00:00
|
|
|
mode: 'history',
|
2017-08-16 21:51:48 +00:00
|
|
|
base: process.env.NODE_ENV === 'production' ? '/' : __dirname, // eslint-disable-line no-process-env
|
2017-01-14 20:12:11 +00:00
|
|
|
linkActiveClass: 'active',
|
2017-03-07 18:34:29 +00:00
|
|
|
// When navigating to another route always scroll to the top
|
|
|
|
|
// To customize the behavior see https://router.vuejs.org/en/advanced/scroll-behavior.html
|
|
|
|
|
scrollBehavior () {
|
|
|
|
|
return { x: 0, y: 0 };
|
|
|
|
|
},
|
2017-06-29 18:49:05 +00:00
|
|
|
// requiresLogin is true by default, isStatic false
|
2016-09-18 19:51:20 +00:00
|
|
|
routes: [
|
2017-09-27 16:57:52 +00:00
|
|
|
{ name: 'register', path: '/register', component: RegisterLoginReset, meta: {requiresLogin: false} },
|
|
|
|
|
{ name: 'login', path: '/login', component: RegisterLoginReset, meta: {requiresLogin: false} },
|
|
|
|
|
{ name: 'resetPassword', path: '/reset-password', component: RegisterLoginReset, meta: {requiresLogin: false} },
|
2017-01-17 18:45:27 +00:00
|
|
|
{ name: 'tasks', path: '/', component: UserTasks },
|
2016-11-18 18:20:25 +00:00
|
|
|
{
|
|
|
|
|
path: '/inventory',
|
2017-01-17 18:45:27 +00:00
|
|
|
component: InventoryContainer,
|
2016-11-18 18:20:25 +00:00
|
|
|
children: [
|
2017-05-22 14:30:52 +00:00
|
|
|
{ name: 'items', path: 'items', component: ItemsPage },
|
Client Redesign: Inventory pages, secondary menu, misc css and design items (#8631)
* add colors palette
* add secondary menu component and style it
* add box shadow to secondary menu
* misc css, fixes for secondary menu
* client: add equipment page with grouping, css: add some styles
* add typography
* more equipment
* stable: fix linting
* equipment: add styles (lots of general styles too)
* remove duplicate google fonts loading
* add dropdowns
* design: white search input background, remove gray from items
* start adding drawer and selected indicator
* wip equipment
* fix equipment
* equipment: correctly bind new properties on items.gear.equipped
* equipment: fix vue binding. version 2
* equipment: fix vue binding. version 3
* back to first fix for equip op, fix for sourcemaps, send http request when an item is equipped, load bootstrap-vue components where needed
* checkboxes and radio buttons
* correctly renders selected items in first postion during the first render
* add search
* general changes, constants part of app state, add popovers
* add toggle switch, rename css
* correct offset
* upgrade deps
* upgrade deps
* drawer and lot of other work
* update equipping mechanism
* finish equipment
* fix compilation and upgrade deps
* use v-show in place of v-if to fix ui issues
* v-show -> v-if
* fix linting in test/client
* fix es6 compilation in test/client
* fix babel compilation for tests
* fix groupsUtilities mixin tests
* client: buttons
* client: buttons: fix colors
* client: finish buttons and dropdowns
* upgrade bootstrap-vue, finish buttons and dropdowns
* fix tasks page layout
* misc fixes for buttons
* add textareas
* fix app menu
* add inputs
* fixes for toggleSwitch
* typography
* checkboxes and radio buttons
* add checkbox icon
* fix equip.js
* extract strings to newClient.json
* add Popover above 'Use Costume' / 'Auto Equip' slider - disable item select if costume-mode and 'useCostume' isn't active
* show "you have disabled your costume" error above the drawer items
* check errorMessage for null
* hide star if costume not enabled
* fix errorMessage (!errorMessage seems not to work for string)
* show minimize / expand icon - always centered by css
* drawer test
* drawer: fix centering on large screens
* fix show more button
* add margin when two dropdowns are next to each other
* adjust the page padding based on the drawer, misc fixes
* drawer fixes
2017-05-16 19:09:55 +00:00
|
|
|
{ name: 'equipment', path: 'equipment', component: EquipmentPage },
|
2017-01-17 18:45:27 +00:00
|
|
|
{ name: 'stable', path: 'stable', component: StablePage },
|
2016-11-18 18:20:25 +00:00
|
|
|
],
|
|
|
|
|
},
|
2017-07-27 17:41:23 +00:00
|
|
|
{
|
|
|
|
|
path: '/shops',
|
|
|
|
|
component: ShopsContainer,
|
|
|
|
|
children: [
|
|
|
|
|
{ name: 'market', path: 'market', component: MarketPage },
|
2017-07-31 23:04:40 +00:00
|
|
|
{ name: 'quests', path: 'quests', component: QuestsPage },
|
|
|
|
|
{ name: 'seasonal', path: 'seasonal', component: SeasonalPage },
|
|
|
|
|
{ name: 'time', path: 'time', component: TimeTravelersPage },
|
2017-07-27 17:41:23 +00:00
|
|
|
],
|
|
|
|
|
},
|
2017-08-20 22:49:47 +00:00
|
|
|
{ name: 'party', path: '/party', component: GroupPage },
|
2017-07-25 14:24:40 +00:00
|
|
|
{ name: 'groupPlan', path: '/group-plans', component: GroupPlansAppPage },
|
2017-08-14 19:19:41 +00:00
|
|
|
{
|
|
|
|
|
name: 'groupPlanDetail',
|
|
|
|
|
path: '/group-plans/:groupId',
|
|
|
|
|
component: GroupPlanIndex,
|
|
|
|
|
props: true,
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
name: 'groupPlanDetailTaskInformation',
|
|
|
|
|
path: '/group-plans/:groupId/task-information',
|
|
|
|
|
component: GroupPlanTaskInformation,
|
|
|
|
|
props: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'groupPlanDetailInformation',
|
|
|
|
|
path: '/group-plans/:groupId/information',
|
2017-08-20 22:49:47 +00:00
|
|
|
component: GroupPage,
|
2017-08-14 19:19:41 +00:00
|
|
|
props: true,
|
|
|
|
|
},
|
2017-10-04 23:26:05 +00:00
|
|
|
{
|
|
|
|
|
name: 'groupPlanBilling',
|
|
|
|
|
path: '/group-plans/:groupId/billing',
|
|
|
|
|
component: GroupPlanBilling,
|
|
|
|
|
props: true,
|
|
|
|
|
},
|
2017-08-14 19:19:41 +00:00
|
|
|
],
|
|
|
|
|
},
|
2017-06-02 20:55:02 +00:00
|
|
|
{
|
2017-07-25 14:24:40 +00:00
|
|
|
path: '/groups',
|
2017-06-02 20:55:02 +00:00
|
|
|
component: GuildIndex,
|
|
|
|
|
children: [
|
2017-07-06 15:38:52 +00:00
|
|
|
{ name: 'tavern', path: 'tavern', component: TavernPage },
|
2017-06-02 20:55:02 +00:00
|
|
|
{
|
|
|
|
|
name: 'myGuilds',
|
|
|
|
|
path: 'myGuilds',
|
|
|
|
|
component: MyGuilds,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'guildsDiscovery',
|
|
|
|
|
path: 'discovery',
|
|
|
|
|
component: GuildsDiscoveryPage,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'guild',
|
2017-07-21 17:00:36 +00:00
|
|
|
path: 'guild/:groupId',
|
2017-08-20 22:49:47 +00:00
|
|
|
component: GroupPage,
|
2017-06-02 20:55:02 +00:00
|
|
|
props: true,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
2017-07-20 20:52:46 +00:00
|
|
|
{
|
|
|
|
|
name: 'challenges',
|
|
|
|
|
path: '/challenges',
|
|
|
|
|
component: ChallengeIndex,
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
name: 'myChallenges',
|
|
|
|
|
path: 'myChallenges',
|
|
|
|
|
component: MyChallenges,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'findChallenges',
|
|
|
|
|
path: 'findChallenges',
|
|
|
|
|
component: FindChallenges,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'challenge',
|
2017-08-17 17:03:32 +00:00
|
|
|
path: ':challengeId',
|
2017-07-20 20:52:46 +00:00
|
|
|
component: ChallengeDetail,
|
|
|
|
|
props: true,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
2016-11-18 18:20:25 +00:00
|
|
|
{
|
|
|
|
|
path: '/user',
|
|
|
|
|
component: ParentPage,
|
|
|
|
|
children: [
|
2017-07-31 19:54:52 +00:00
|
|
|
{ name: 'stats', path: 'stats', component: ProfilePage },
|
|
|
|
|
{ name: 'achievements', path: 'achievements', component: ProfilePage },
|
2017-07-18 04:18:17 +00:00
|
|
|
{ name: 'profile', path: 'profile', component: ProfilePage },
|
2017-07-20 18:01:00 +00:00
|
|
|
{
|
|
|
|
|
name: 'settings',
|
|
|
|
|
path: 'settings',
|
|
|
|
|
component: Settings,
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
name: 'site',
|
|
|
|
|
path: 'site',
|
|
|
|
|
component: Site,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'api',
|
|
|
|
|
path: 'api',
|
|
|
|
|
component: API,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'dataExport',
|
|
|
|
|
path: 'data-export',
|
|
|
|
|
component: DataExport,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'promoCode',
|
|
|
|
|
path: 'promo-code',
|
|
|
|
|
component: PromoCode,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'subscription',
|
|
|
|
|
path: 'subscription',
|
|
|
|
|
component: Subscription,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'notifications',
|
|
|
|
|
path: 'notifications',
|
|
|
|
|
component: Notifications,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
2016-11-18 18:20:25 +00:00
|
|
|
],
|
|
|
|
|
},
|
2017-07-20 18:20:53 +00:00
|
|
|
{
|
|
|
|
|
path: '/static',
|
2017-09-15 18:59:15 +00:00
|
|
|
component: StaticWrapper,
|
2017-07-20 18:20:53 +00:00
|
|
|
children: [
|
2017-08-22 16:26:53 +00:00
|
|
|
{ name: 'app', path: 'app', component: AppPage, meta: {requiresLogin: false}},
|
|
|
|
|
{ name: 'clearBrowserData', path: 'clear-browser-data', component: ClearBrowserDataPage, meta: {requiresLogin: false}},
|
2017-08-30 22:59:31 +00:00
|
|
|
{ name: 'communityGuidelines', path: 'community-guidelines', component: CommunityGuidelinesPage, meta: {requiresLogin: false}},
|
2017-08-22 16:26:53 +00:00
|
|
|
{ name: 'contact', path: 'contact', component: ContactPage, meta: {requiresLogin: false}},
|
|
|
|
|
{ name: 'faq', path: 'faq', component: FAQPage, meta: {requiresLogin: false}},
|
|
|
|
|
{ name: 'features', path: 'features', component: FeaturesPage, meta: {requiresLogin: false}},
|
|
|
|
|
{ name: 'groupPlans', path: 'group-plans', component: GroupPlansPage, meta: {requiresLogin: false}},
|
2017-09-15 18:59:15 +00:00
|
|
|
{ name: 'home', path: 'home', component: HomePage, meta: {requiresLogin: false} },
|
2017-08-22 16:26:53 +00:00
|
|
|
{ name: 'merch', path: 'merch', component: MerchPage, meta: {requiresLogin: false}},
|
2017-09-30 15:48:24 +00:00
|
|
|
{ name: 'news', path: 'new-stuff', component: NewsPage, meta: {requiresLogin: false}},
|
2017-08-22 16:26:53 +00:00
|
|
|
{ name: 'overview', path: 'overview', component: OverviewPage, meta: {requiresLogin: false}},
|
|
|
|
|
{ name: 'plans', path: 'plans', component: GroupPlansPage, meta: {requiresLogin: false}},
|
|
|
|
|
{ name: 'pressKit', path: 'press-kit', component: PressKitPage, meta: {requiresLogin: false}},
|
2017-08-07 20:26:17 +00:00
|
|
|
{ name: 'privacy', path: 'privacy', component: PrivacyPage, meta: {requiresLogin: false}},
|
|
|
|
|
{ name: 'terms', path: 'terms', component: TermsPage, meta: {requiresLogin: false}},
|
2017-09-28 17:19:15 +00:00
|
|
|
{ name: 'notFound', path: 'not-found', component: NotFoundPage, meta: {requiresLogin: false} },
|
2017-07-20 18:20:53 +00:00
|
|
|
],
|
|
|
|
|
},
|
2017-07-25 14:24:40 +00:00
|
|
|
{
|
|
|
|
|
path: '/hall',
|
|
|
|
|
component: HallPage,
|
|
|
|
|
children: [
|
|
|
|
|
{ name: 'patrons', path: 'patrons', component: PatronsPage },
|
|
|
|
|
{ name: 'contributors', path: 'contributors', component: HeroesPage },
|
|
|
|
|
],
|
|
|
|
|
},
|
2017-09-28 17:19:15 +00:00
|
|
|
{ path: '*', redirect: { name: 'notFound' } },
|
2016-09-18 19:51:20 +00:00
|
|
|
],
|
2016-12-29 19:24:08 +00:00
|
|
|
});
|
2017-06-29 18:49:05 +00:00
|
|
|
|
|
|
|
|
const store = getStore();
|
|
|
|
|
|
|
|
|
|
router.beforeEach(function routerGuard (to, from, next) {
|
|
|
|
|
const isUserLoggedIn = store.state.isUserLoggedIn;
|
|
|
|
|
const routeRequiresLogin = to.meta.requiresLogin !== false;
|
|
|
|
|
|
|
|
|
|
if (!isUserLoggedIn && routeRequiresLogin) {
|
|
|
|
|
// Redirect to the login page unless the user is trying to reach the
|
|
|
|
|
// root of the website, in which case show the home page.
|
2017-09-27 18:59:49 +00:00
|
|
|
// Pass the requested page as a query parameter to redirect later.
|
|
|
|
|
|
|
|
|
|
const redirectTo = to.path === '/' ? 'home' : 'login';
|
|
|
|
|
return next({
|
|
|
|
|
name: redirectTo,
|
|
|
|
|
query: redirectTo === 'login' ? {
|
|
|
|
|
redirectTo: to.path,
|
|
|
|
|
} : null,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Keep the redirectTo query param when going from login to register
|
|
|
|
|
// !to.query.redirectTo is to avoid entering a loop of infinite redirects
|
|
|
|
|
if (to.name === 'register' && !to.query.redirectTo && from.name === 'login' && from.query.redirectTo) {
|
|
|
|
|
return next({
|
|
|
|
|
name: 'register',
|
|
|
|
|
query: {
|
|
|
|
|
redirectTo: from.query.redirectTo,
|
|
|
|
|
},
|
|
|
|
|
});
|
2017-06-29 18:49:05 +00:00
|
|
|
}
|
|
|
|
|
|
2017-09-07 12:16:39 +00:00
|
|
|
if (isUserLoggedIn && (to.name === 'login' || to.name === 'register')) {
|
|
|
|
|
return next({name: 'tasks'});
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-08 19:23:58 +00:00
|
|
|
Analytics.track({
|
|
|
|
|
hitType: 'pageview',
|
|
|
|
|
eventCategory: 'navigation',
|
|
|
|
|
eventAction: 'navigate',
|
|
|
|
|
page: to.name || to.path,
|
|
|
|
|
});
|
|
|
|
|
|
2017-06-29 18:49:05 +00:00
|
|
|
next();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export default router;
|