feat: ログインするアカウントのIDをクエリ文字列で指定する機能
This commit is contained in:
parent
fa0814f939
commit
4f7ae81d5f
2 changed files with 32 additions and 0 deletions
|
@ -37,6 +37,8 @@ import { isMobile } from '@client/scripts/is-mobile';
|
||||||
import { initializeSw } from '@client/scripts/initialize-sw';
|
import { initializeSw } from '@client/scripts/initialize-sw';
|
||||||
import { reloadChannel } from '@client/scripts/unison-reload';
|
import { reloadChannel } from '@client/scripts/unison-reload';
|
||||||
import { reactionPicker } from '@client/scripts/reaction-picker';
|
import { reactionPicker } from '@client/scripts/reaction-picker';
|
||||||
|
import { deleteLoginId } from '@client/scripts/login-id';
|
||||||
|
import { getAccountFromId } from '@client/scripts/get-account-from-id';
|
||||||
|
|
||||||
console.info(`Misskey v${version}`);
|
console.info(`Misskey v${version}`);
|
||||||
|
|
||||||
|
@ -116,6 +118,25 @@ const html = document.documentElement;
|
||||||
html.setAttribute('lang', lang);
|
html.setAttribute('lang', lang);
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
//#region loginId
|
||||||
|
const params = new URLSearchParams(location.search);
|
||||||
|
const loginId = params.get('loginId');
|
||||||
|
|
||||||
|
if (loginId) {
|
||||||
|
const target = deleteLoginId(location.href);
|
||||||
|
|
||||||
|
if (!$i || $i.id !== loginId) {
|
||||||
|
const account = await getAccountFromId(loginId);
|
||||||
|
if (account) {
|
||||||
|
login(account.token, target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
history.replaceState({ misskey: 'loginId' }, '', target);
|
||||||
|
}
|
||||||
|
|
||||||
|
//#endregion
|
||||||
|
|
||||||
//#region Fetch user
|
//#region Fetch user
|
||||||
if ($i && $i.token) {
|
if ($i && $i.token) {
|
||||||
if (_DEV_) {
|
if (_DEV_) {
|
||||||
|
|
11
src/client/scripts/login-id.ts
Normal file
11
src/client/scripts/login-id.ts
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
export function appendLoginId(url: string, loginId: string) {
|
||||||
|
const u = new URL(url, origin);
|
||||||
|
u.searchParams.append('loginId', loginId);
|
||||||
|
return u.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deleteLoginId(url: string) {
|
||||||
|
const u = new URL(url);
|
||||||
|
u.searchParams.delete('loginId');
|
||||||
|
return u.toString();
|
||||||
|
}
|
Loading…
Reference in a new issue