0
0
Fork 0

ホスト名の正規化とMiAuth以外でログイン時のメッセージを強化

This commit is contained in:
Xeltica 2020-08-04 20:11:14 +09:00
parent f06fcc2056
commit c34f711f0b

View file

@ -17,11 +17,22 @@ router.get('/', async ctx => {
}); });
router.get('/login', async ctx => { router.get('/login', async ctx => {
const host = ctx.query.host as string | undefined; let host = ctx.query.host as string | undefined;
if (!host) { if (!host) {
await die(ctx, 'ホストを空欄にしてはいけない'); await die(ctx, 'ホストを空欄にしてはいけない');
return; return;
} }
const meta = await api<{ name: string, uri: string, features: Record<string, boolean | undefined> }>(host, 'meta', {});
// MiAuth 以外はサポートしていない
if (!meta.features.miauth) {
await die(ctx, 'ごめんなさい。お使いのインスタンス "' + (meta.name || host) + '" はまだサポートされていません。現在、MiAuth 認証方式をサポートするバージョンの Misskey のみご利用頂けます。対象の Misskey バージョンは Misskey v12, Groundpolis v3 の最新版です。インスタンス管理者にご問い合わせください。');
return;
}
// ホスト名の正規化
host = meta.uri.replace(/^https?:\/\//, '');
const session = uuid(); const session = uuid();
const name = encodeURI('みす廃あらーと'); const name = encodeURI('みす廃あらーと');
const permission = encodeURI('write:notes'); const permission = encodeURI('write:notes');