2020-03-28 04:24:37 +02:00
|
|
|
<template>
|
2020-12-19 03:55:52 +02:00
|
|
|
<div v-if="$i">
|
2021-11-19 12:36:12 +02:00
|
|
|
<div v-if="state == 'waiting'" class="waiting _section">
|
2020-03-28 04:24:37 +02:00
|
|
|
<div class="_content">
|
2020-10-17 14:12:00 +03:00
|
|
|
<MkLoading/>
|
2020-03-28 04:24:37 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-11-19 12:36:12 +02:00
|
|
|
<div v-if="state == 'denied'" class="denied _section">
|
2020-03-28 04:24:37 +02:00
|
|
|
<div class="_content">
|
2020-12-26 03:47:36 +02:00
|
|
|
<p>{{ $ts._auth.denied }}</p>
|
2020-03-28 04:24:37 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-11-19 12:36:12 +02:00
|
|
|
<div v-else-if="state == 'accepted'" class="accepted _section">
|
2020-03-28 04:24:37 +02:00
|
|
|
<div class="_content">
|
2020-12-26 03:47:36 +02:00
|
|
|
<p v-if="callback">{{ $ts._auth.callback }}<MkEllipsis/></p>
|
|
|
|
<p v-else>{{ $ts._auth.pleaseGoBack }}</p>
|
2020-03-28 04:24:37 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-11-19 12:36:12 +02:00
|
|
|
<div v-else class="_section">
|
|
|
|
<div v-if="name" class="_title">{{ $t('_auth.shareAccess', { name: name }) }}</div>
|
|
|
|
<div v-else class="_title">{{ $ts._auth.shareAccessAsk }}</div>
|
2020-03-28 04:24:37 +02:00
|
|
|
<div class="_content">
|
2020-12-26 03:47:36 +02:00
|
|
|
<p>{{ $ts._auth.permissionAsk }}</p>
|
2020-03-28 04:24:37 +02:00
|
|
|
<ul>
|
2020-10-17 14:12:00 +03:00
|
|
|
<li v-for="p in permission" :key="p">{{ $t(`_permissions.${p}`) }}</li>
|
2020-03-28 04:24:37 +02:00
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
<div class="_footer">
|
2021-11-19 12:36:12 +02:00
|
|
|
<MkButton inline @click="deny">{{ $ts.cancel }}</MkButton>
|
|
|
|
<MkButton inline primary @click="accept">{{ $ts.accept }}</MkButton>
|
2020-03-28 04:24:37 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-11-19 12:36:12 +02:00
|
|
|
<div v-else class="signin">
|
2020-10-17 14:12:00 +03:00
|
|
|
<MkSignin @login="onLogin"/>
|
2020-03-28 04:24:37 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 14:12:00 +03:00
|
|
|
import { defineComponent } from 'vue';
|
2021-11-11 19:02:25 +02:00
|
|
|
import MkSignin from '@/components/signin.vue';
|
|
|
|
import MkButton from '@/components/ui/button.vue';
|
|
|
|
import * as os from '@/os';
|
|
|
|
import { login } from '@/account';
|
2022-06-03 15:22:03 +03:00
|
|
|
import { appendQuery, query } from '@/scripts/url';
|
2020-03-28 04:24:37 +02:00
|
|
|
|
2020-10-17 14:12:00 +03:00
|
|
|
export default defineComponent({
|
2020-03-28 04:24:37 +02:00
|
|
|
components: {
|
|
|
|
MkSignin,
|
|
|
|
MkButton,
|
|
|
|
},
|
2022-06-20 11:38:49 +03:00
|
|
|
props: ['session', 'callback', 'name', 'icon', 'permission'],
|
2020-03-28 04:24:37 +02:00
|
|
|
data() {
|
|
|
|
return {
|
2022-06-20 11:38:49 +03:00
|
|
|
state: null,
|
2020-03-28 04:24:37 +02:00
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
async accept() {
|
|
|
|
this.state = 'waiting';
|
2020-10-17 14:12:00 +03:00
|
|
|
await os.api('miauth/gen-token', {
|
2020-03-28 04:24:37 +02:00
|
|
|
session: this.session,
|
|
|
|
name: this.name,
|
2020-03-28 11:33:24 +02:00
|
|
|
iconUrl: this.icon,
|
2020-03-29 11:04:22 +03:00
|
|
|
permission: this.permission,
|
2020-03-28 04:24:37 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
this.state = 'accepted';
|
|
|
|
if (this.callback) {
|
2022-06-03 15:22:03 +03:00
|
|
|
location.href = appendQuery(this.callback, query({
|
2022-06-20 11:38:49 +03:00
|
|
|
session: this.session,
|
2022-06-03 15:22:03 +03:00
|
|
|
}));
|
2020-03-28 04:24:37 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
deny() {
|
|
|
|
this.state = 'denied';
|
|
|
|
},
|
|
|
|
onLogin(res) {
|
2020-12-19 03:55:52 +02:00
|
|
|
login(res.i);
|
2022-06-20 11:38:49 +03:00
|
|
|
},
|
|
|
|
},
|
2020-03-28 04:24:37 +02:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
|
|
</style>
|