2FAuth/resources/js/routes.js

88 lines
4.8 KiB
JavaScript
Raw Normal View History

2020-01-16 13:50:53 +01:00
import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
import Start from './views/Start'
import Capture from './views/Capture'
2020-01-18 18:19:37 +01:00
import Accounts from './views/Accounts'
import CreateAccount from './views/twofaccounts/Create'
import EditAccount from './views/twofaccounts/Edit'
import ImportAccount from './views/twofaccounts/Import'
import QRcodeAccount from './views/twofaccounts/QRcode'
import Groups from './views/Groups'
import CreateGroup from './views/groups/Create'
import EditGroup from './views/groups/Edit'
2020-01-18 18:19:37 +01:00
import Login from './views/auth/Login'
import Register from './views/auth/Register'
import PasswordRequest from './views/auth/password/Request'
import PasswordReset from './views/auth/password/Reset'
2022-03-15 14:47:07 +01:00
import WebauthnLost from './views/auth/webauthn/Lost'
import WebauthnRecover from './views/auth/webauthn/Recover'
import SettingsOptions from './views/settings/Options'
import SettingsAccount from './views/settings/Account'
import SettingsOAuth from './views/settings/OAuth'
2022-03-15 14:47:07 +01:00
import SettingsWebAuthn from './views/settings/WebAuthn'
import EditCredential from './views/settings/Credentials/Edit'
import GeneratePAT from './views/settings/PATokens/Create'
2020-01-27 21:41:47 +01:00
import Errors from './views/Error'
2020-01-16 13:50:53 +01:00
const router = new Router({
mode: 'history',
routes: [
{ path: '/start', name: 'start', component: Start, meta: { requiresAuth: true }, props: true },
{ path: '/capture', name: 'capture', component: Capture, meta: { requiresAuth: true }, props: true },
{ path: '/accounts', name: 'accounts', component: Accounts, meta: { requiresAuth: true }, alias: '/', props: true },
{ path: '/account/create', name: 'createAccount', component: CreateAccount, meta: { requiresAuth: true } },
{ path: '/account/import', name: 'importAccounts', component: ImportAccount, meta: { requiresAuth: true } },
{ path: '/account/:twofaccountId/edit', name: 'editAccount', component: EditAccount, meta: { requiresAuth: true } },
{ path: '/account/:twofaccountId/qrcode', name: 'showQRcode', component: QRcodeAccount, meta: { requiresAuth: true } },
{ path: '/groups', name: 'groups', component: Groups, meta: { requiresAuth: true }, props: true },
{ path: '/group/create', name: 'createGroup', component: CreateGroup, meta: { requiresAuth: true } },
{ path: '/group/:groupId/edit', name: 'editGroup', component: EditGroup, meta: { requiresAuth: true }, props: true },
{ path: '/settings/options', name: 'settings.options', component: SettingsOptions, meta: { requiresAuth: true } },
{ path: '/settings/account', name: 'settings.account', component: SettingsAccount, meta: { requiresAuth: true } },
{ path: '/settings/oauth', name: 'settings.oauth', component: SettingsOAuth, meta: { requiresAuth: true } },
2022-03-28 17:09:29 +02:00
{ path: '/settings/webauthn/:credentialId/edit', name: 'settings.webauthn.editCredential', component: EditCredential, meta: { requiresAuth: true }, props: true },
2022-03-15 14:47:07 +01:00
{ path: '/settings/webauthn', name: 'settings.webauthn', component: SettingsWebAuthn, meta: { requiresAuth: true } },
{ path: '/settings/oauth/pat/create', name: 'settings.oauth.generatePAT', component: GeneratePAT, meta: { requiresAuth: true } },
2020-01-16 13:50:53 +01:00
{ path: '/login', name: 'login', component: Login, meta: { disabledWithAuthProxy: true } },
{ path: '/register', name: 'register', component: Register, meta: { disabledWithAuthProxy: true } },
{ path: '/password/request', name: 'password.request', component: PasswordRequest, meta: { disabledWithAuthProxy: true } },
{ path: '/password/reset/:token', name: 'password.reset', component: PasswordReset, meta: { disabledWithAuthProxy: true } },
{ path: '/webauthn/lost', name: 'webauthn.lost', component: WebauthnLost, meta: { disabledWithAuthProxy: true } },
{ path: '/webauthn/recover', name: 'webauthn.recover', component: WebauthnRecover, meta: { disabledWithAuthProxy: true } },
2020-01-27 21:41:47 +01:00
{ path: '/flooded', name: 'flooded',component: Errors,props: true },
{ path: '/error', name: 'genericError',component: Errors,props: true },
{ path: '/404', name: '404',component: Errors,props: true },
2020-01-16 13:50:53 +01:00
{ path: '*', redirect: { name: '404' } }
],
});
let isFirstLoad = true;
router.beforeEach((to, from, next) => {
if( to.name === 'accounts') {
to.params.isFirstLoad = isFirstLoad ? true : false
isFirstLoad = false;
}
if (to.matched.some(record => record.meta.disabledWithAuthProxy)) {
if (window.appConfig.proxyAuth) {
next({ name: 'accounts' })
}
else next()
}
else next()
});
router.afterEach(to => {
Vue.$storage.set('lastRoute', to.name)
});
2020-01-16 13:50:53 +01:00
export default router