summaryrefslogtreecommitdiff
path: root/packages/frontend/src/nirax.ts
diff options
context:
space:
mode:
authorChocolate Pie <106949016+chocolate-pie@users.noreply.github.com>2023-07-08 08:58:35 +0900
committerGitHub <noreply@github.com>2023-07-08 08:58:35 +0900
commitbd843863d029b72b4a9c0b97ee7296e4e60ad8d6 (patch)
tree0ed5fddd0ae1b8a864f1c5db23f8a417ea550968 /packages/frontend/src/nirax.ts
parentfix(backend): ジョブキュー再試行時のタイミングずれによる... (diff)
downloadsharkey-bd843863d029b72b4a9c0b97ee7296e4e60ad8d6.tar.gz
sharkey-bd843863d029b72b4a9c0b97ee7296e4e60ad8d6.tar.bz2
sharkey-bd843863d029b72b4a9c0b97ee7296e4e60ad8d6.zip
fix: 非ログイン時にクレデンシャルが必要なページに行くとエラーが出る問題を修正 (#10973)
* 非ログイン時にクレデンシャルが必要なページに行くとエラーが出る問題を修正 (misskey-dev/misskey#10922) * Update CHANGELOG.md * fix * Update CHANGELOG.md * Update CHANGELOG.md
Diffstat (limited to 'packages/frontend/src/nirax.ts')
-rw-r--r--packages/frontend/src/nirax.ts14
1 files changed, 9 insertions, 5 deletions
diff --git a/packages/frontend/src/nirax.ts b/packages/frontend/src/nirax.ts
index 40348ded17..3fa6bd55e2 100644
--- a/packages/frontend/src/nirax.ts
+++ b/packages/frontend/src/nirax.ts
@@ -2,7 +2,6 @@
import { EventEmitter } from 'eventemitter3';
import { Component, shallowRef, ShallowRef } from 'vue';
-import { pleaseLogin } from '@/scripts/please-login';
import { safeURIDecode } from '@/scripts/safe-uri-decode';
type RouteDef = {
@@ -23,7 +22,7 @@ type ParsedPath = (string | {
optional?: boolean;
})[];
-export type Resolved = { route: RouteDef; props: Map<string, string>; child?: Resolved; };
+export type Resolved = { route: RouteDef; props: Map<string, string | boolean>; child?: Resolved; };
function parsePath(path: string): ParsedPath {
const res = [] as ParsedPath;
@@ -75,15 +74,19 @@ export class Router extends EventEmitter<{
public currentRef: ShallowRef<Resolved> = shallowRef();
public currentRoute: ShallowRef<RouteDef> = shallowRef();
private currentPath: string;
+ private isLoggedIn: boolean;
+ private notFoundPageComponent: Component;
private currentKey = Date.now().toString();
public navHook: ((path: string, flag?: any) => boolean) | null = null;
- constructor(routes: Router['routes'], currentPath: Router['currentPath']) {
+ constructor(routes: Router['routes'], currentPath: Router['currentPath'], isLoggedIn: boolean, notFoundPageComponent: Component) {
super();
this.routes = routes;
this.currentPath = currentPath;
+ this.isLoggedIn = isLoggedIn;
+ this.notFoundPageComponent = notFoundPageComponent;
this.navigate(currentPath, null, false);
}
@@ -212,8 +215,9 @@ export class Router extends EventEmitter<{
throw new Error('no route found for: ' + path);
}
- if (res.route.loginRequired) {
- pleaseLogin('/');
+ if (res.route.loginRequired && !this.isLoggedIn) {
+ res.route.component = this.notFoundPageComponent;
+ res.props.set('showLoginPopup', true);
}
const isSamePath = beforePath === path;