jormungandr-bite/packages/client/src/pages/auth.form.vue

69 lines
1.3 KiB
Vue
Raw Normal View History

<template>
2023-04-07 18:01:42 -06:00
<section class="_section">
<div class="_title">
{{ i18n.t("_auth.shareAccess", { name: app.name }) }}
</div>
<div class="_content">
<h2>{{ app.name }}</h2>
<p class="id">{{ app.id }}</p>
<p class="description">{{ app.description }}</p>
</div>
<div class="_content">
<h2>{{ i18n.ts._auth.permissionAsk }}</h2>
<ul>
<li v-for="p in app.permission" :key="p">
{{ i18n.t(`_permissions.${p}`) }}
</li>
</ul>
</div>
<div class="_footer">
<MkButton inline @click="cancel">{{ i18n.ts.cancel }}</MkButton>
<MkButton inline primary @click="accept">{{
i18n.ts.accept
}}</MkButton>
</div>
</section>
</template>
<script lang="ts" setup>
2023-04-07 18:01:42 -06:00
import { defineComponent } from "vue";
import MkButton from "@/components/MkButton.vue";
import * as os from "@/os";
import { i18n } from "@/i18n";
const emit = defineEmits<{
2023-04-07 18:01:42 -06:00
(ev: "denied"): void;
(ev: "accepted"): void;
}>();
const props = defineProps<{
session: {
app: {
name: string;
id: string;
description: string;
permission: string[];
};
token: string;
};
}>();
const app = props.session.app;
function cancel() {
2023-04-07 18:01:42 -06:00
os.api("auth/deny", {
token: props.session.token,
}).then(() => {
2023-04-07 18:01:42 -06:00
emit("denied");
});
}
function accept() {
2023-04-07 18:01:42 -06:00
os.api("auth/accept", {
token: props.session.token,
}).then(() => {
2023-04-07 18:01:42 -06:00
emit("accepted");
});
}
</script>