1
0
forked from mirror/misskey
mi.moris.day/packages/client/src/scripts/please-login.ts
Johann150 7f111f4474
Prevent access to user pages when not logged in [v2] (#8904)
* do not throw error when navigating

* enhance: add loginRequired to router

This allows client pages to require logging in before displaying the
page, useful for example for user settings pages.

* add login requirements

Co-authored-by: Andreas Nedbal <git@pixelde.su>
2022-06-29 18:26:06 +09:00

22 lines
482 B
TypeScript

import { defineAsyncComponent } from 'vue';
import { $i } from '@/account';
import { i18n } from '@/i18n';
import { popup } from '@/os';
export function pleaseLogin(path?: string) {
if ($i) return;
popup(defineAsyncComponent(() => import('@/components/signin-dialog.vue')), {
autoSet: true,
message: i18n.ts.signinRequired
}, {
cancelled: () => {
if (path) {
window.location.href = path;
}
},
}, 'closed');
if (!path) throw new Error('signin required');
}