feat: クライアントでログインするアカウントidを指定するクエリ(loginId=:userId) (#7929)
* feat: ログインするアカウントのIDをクエリ文字列で指定する機能 * await? * rename
This commit is contained in:
@@ -37,6 +37,8 @@ import { isMobile } from '@client/scripts/is-mobile';
|
||||
import { initializeSw } from '@client/scripts/initialize-sw';
|
||||
import { reloadChannel } from '@client/scripts/unison-reload';
|
||||
import { reactionPicker } from '@client/scripts/reaction-picker';
|
||||
import { getUrlWithoutLoginId } from '@client/scripts/login-id';
|
||||
import { getAccountFromId } from '@client/scripts/get-account-from-id';
|
||||
|
||||
console.info(`Misskey v${version}`);
|
||||
|
||||
@@ -116,6 +118,25 @@ const html = document.documentElement;
|
||||
html.setAttribute('lang', lang);
|
||||
//#endregion
|
||||
|
||||
//#region loginId
|
||||
const params = new URLSearchParams(location.search);
|
||||
const loginId = params.get('loginId');
|
||||
|
||||
if (loginId) {
|
||||
const target = getUrlWithoutLoginId(location.href);
|
||||
|
||||
if (!$i || $i.id !== loginId) {
|
||||
const account = await getAccountFromId(loginId);
|
||||
if (account) {
|
||||
await login(account.token, target);
|
||||
}
|
||||
}
|
||||
|
||||
history.replaceState({ misskey: 'loginId' }, '', target);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region Fetch user
|
||||
if ($i && $i.token) {
|
||||
if (_DEV_) {
|
||||
|
Reference in New Issue
Block a user