2023-07-28 14:02:58 +09:00
|
|
|
<!--
|
2024-02-14 00:59:27 +09:00
|
|
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-28 14:02:58 +09:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2023-07-27 18:51:58 +09:00
|
|
|
<template>
|
|
|
|
<MkStickyContainer>
|
|
|
|
<template #header><MkPageHeader/></template>
|
|
|
|
<MkSpacer :contentMax="800">
|
|
|
|
<div v-if="$i">
|
|
|
|
<div v-if="permissions.length > 0">
|
2024-01-20 08:11:59 +09:00
|
|
|
<p v-if="name">{{ i18n.tsx._auth.permission({ name }) }}</p>
|
2023-07-27 18:51:58 +09:00
|
|
|
<p v-else>{{ i18n.ts._auth.permissionAsk }}</p>
|
|
|
|
<ul>
|
2024-01-20 08:11:59 +09:00
|
|
|
<li v-for="p in permissions" :key="p">{{ i18n.ts._permissions[p] }}</li>
|
2023-07-27 18:51:58 +09:00
|
|
|
</ul>
|
|
|
|
</div>
|
2024-01-20 08:11:59 +09:00
|
|
|
<div v-if="name">{{ i18n.tsx._auth.shareAccess({ name }) }}</div>
|
2023-07-27 18:51:58 +09:00
|
|
|
<div v-else>{{ i18n.ts._auth.shareAccessAsk }}</div>
|
|
|
|
<form :class="$style.buttons" action="/oauth/decision" accept-charset="utf-8" method="post">
|
|
|
|
<input name="login_token" type="hidden" :value="$i.token"/>
|
|
|
|
<input name="transaction_id" type="hidden" :value="transactionIdMeta?.content"/>
|
|
|
|
<MkButton inline name="cancel" value="cancel">{{ i18n.ts.cancel }}</MkButton>
|
|
|
|
<MkButton inline primary>{{ i18n.ts.accept }}</MkButton>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
<div v-else>
|
|
|
|
<p :class="$style.loginMessage">{{ i18n.ts._auth.pleaseLogin }}</p>
|
|
|
|
<MkSignin @login="onLogin"/>
|
|
|
|
</div>
|
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
import MkSignin from '@/components/MkSignin.vue';
|
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2023-09-19 16:37:43 +09:00
|
|
|
import { $i, login } from '@/account.js';
|
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
2023-07-27 18:51:58 +09:00
|
|
|
|
|
|
|
const transactionIdMeta = document.querySelector<HTMLMetaElement>('meta[name="misskey:oauth:transaction-id"]');
|
|
|
|
if (transactionIdMeta) {
|
|
|
|
transactionIdMeta.remove();
|
|
|
|
}
|
|
|
|
|
|
|
|
const name = document.querySelector<HTMLMetaElement>('meta[name="misskey:oauth:client-name"]')?.content;
|
|
|
|
const permissions = document.querySelector<HTMLMetaElement>('meta[name="misskey:oauth:scope"]')?.content.split(' ') ?? [];
|
|
|
|
|
|
|
|
function onLogin(res): void {
|
|
|
|
login(res.i);
|
|
|
|
}
|
|
|
|
|
2024-02-16 16:17:09 +09:00
|
|
|
definePageMetadata(() => ({
|
2023-07-27 18:51:58 +09:00
|
|
|
title: 'OAuth',
|
|
|
|
icon: 'ti ti-apps',
|
2024-02-16 16:17:09 +09:00
|
|
|
}));
|
2023-07-27 18:51:58 +09:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" module>
|
|
|
|
.buttons {
|
|
|
|
margin-top: 16px;
|
|
|
|
display: flex;
|
|
|
|
gap: 8px;
|
|
|
|
flex-wrap: wrap;
|
|
|
|
}
|
|
|
|
|
|
|
|
.loginMessage {
|
|
|
|
text-align: center;
|
|
|
|
margin: 8px 0 24px;
|
|
|
|
}
|
|
|
|
</style>
|