Skip to content

Commit 0eecad1

Browse files
authored
Avoid redundant navigation in afterLogin (#339)
Fix #282
1 parent fda160e commit 0eecad1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/lib/auth-vue-router.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,26 @@ export default class AuthVueRouter {
1818

1919
public async push(to: RawLocation | string) {
2020
if (this.router.currentRoute.path !== to) {
21-
await this.router.push(to);
21+
return await this.router.push(to);
2222
}
2323
}
2424

2525
public async afterLogin(redirect?: RawLocation | string | null) {
2626
let promise: Promise<Route | undefined> = Promise.resolve(undefined);
2727
if (redirect) {
28-
promise = this.router.push(redirect);
28+
promise = this.push(redirect);
2929
} else if (this.router.currentRoute.query.nextUrl) {
3030
const nextUrl = this.router.currentRoute.query.nextUrl;
3131
if (typeof nextUrl === 'string') {
32-
promise = this.router.push(nextUrl);
32+
promise = this.push(nextUrl);
3333
}
3434
} else {
35-
promise = this.router.push('/');
35+
promise = this.push('/');
3636
}
3737
if (promise) {
3838
promise.catch(async () => {
3939
const result = redirect || '/';
40-
await this.router.push(result);
40+
await this.push(result);
4141
});
4242
}
4343
return promise;

0 commit comments

Comments
 (0)