From ca8785f89f4b80abdc75aac54fb55e49ea088f9c Mon Sep 17 00:00:00 2001 From: Alexander Lichter Date: Tue, 13 Mar 2018 07:33:53 +0100 Subject: [PATCH] feat(redirect): add full path redirect option (#96) --- docs/options.md | 6 ++++++ lib/auth/auth.js | 2 +- lib/defaults.js | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/options.md b/docs/options.md index 46e48cbe2..4bd1a2414 100644 --- a/docs/options.md +++ b/docs/options.md @@ -66,6 +66,12 @@ If enabled, user will be automatically logged out if any error happens. (For exa If enabled, user will redirect back to the original guarded route instead of `redirect.home`. +### `fullPathRedirect` + +Default: `false` + +If true, use the full route path with query parameters for redirect + ### `vuex.namespace` * Default: `auth` diff --git a/lib/auth/auth.js b/lib/auth/auth.js index 4fbf5d3b9..eb6b36537 100644 --- a/lib/auth/auth.js +++ b/lib/auth/auth.js @@ -435,7 +435,7 @@ export default class Auth { return } - const from = this.ctx.route.path + const from = this.options.fullPathRedirect ? this.ctx.route.path : this.ctx.route.fullPath let to = this.options.redirect[name] if (!to) { diff --git a/lib/defaults.js b/lib/defaults.js index b65618c73..a06b963fb 100644 --- a/lib/defaults.js +++ b/lib/defaults.js @@ -13,6 +13,8 @@ module.exports = { rewriteRedirects: true, + fullPathRedirect: false, + redirect: { login: '/login', logout: '/',