summaryrefslogtreecommitdiff
path: root/packages/frontend/src/pages/auth.form.vue
blob: f8484185f5d8ebb3bd963169beb22c56e7e8cb51 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<template>
	<section>
		<div v-if="app.permission.length > 0">
			<p>{{ $t('_auth.permission', { name }) }}</p>
			<ul>
				<li v-for="p in app.permission" :key="p">{{ $t(`_permissions.${p}`) }}</li>
			</ul>
		</div>
		<div>{{ i18n.t('_auth.shareAccess', { name: `${name} (${app.id})` }) }}</div>
		<div :class="$style.buttons">
			<MkButton inline @click="cancel">{{ i18n.ts.cancel }}</MkButton>
			<MkButton inline primary @click="accept">{{ i18n.ts.accept }}</MkButton>
		</div>
	</section>
</template>

<script lang="ts" setup>
import { } from 'vue';
import MkButton from '@/components/MkButton.vue';
import * as os from '@/os';
import { i18n } from '@/i18n';
import { AuthSession } from 'misskey-js/built/entities';

const props = defineProps<{
	session: AuthSession;
}>();

const emit = defineEmits<{
	(event: 'accepted'): void;
	(event: 'denied'): void;
}>();

const app = $computed(() => props.session.app);

const name = $computed(() => {
	const el = document.createElement('div');
	el.textContent = app.name;
	return el.innerHTML;
});

function cancel() {
	os.api('auth/deny', {
		token: props.session.token,
	}).then(() => {
		emit('denied');
	});
}

function accept() {
	os.api('auth/accept', {
		token: props.session.token,
	}).then(() => {
		emit('accepted');
	});
}

</script>

<style lang="scss" module>
.buttons {
	margin-top: 16px;
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}
</style>