2020-03-28 04:24:37 +02:00
|
|
|
<template>
|
2020-12-19 03:55:52 +02:00
|
|
|
<div v-if="$i">
|
2020-10-17 14:12:00 +03:00
|
|
|
<div class="waiting _section" v-if="state == 'waiting'">
|
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>
|
2020-10-17 14:12:00 +03:00
|
|
|
<div class="denied _section" v-if="state == 'denied'">
|
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>
|
2020-10-17 14:12:00 +03:00
|
|
|
<div class="accepted _section" v-else-if="state == 'accepted'">
|
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>
|
2020-10-17 14:12:00 +03:00
|
|
|
<div class="_section" v-else>
|
2020-03-28 04:24:37 +02:00
|
|
|
<div class="_title" v-if="name">{{ $t('_auth.shareAccess', { name: name }) }}</div>
|
2020-12-26 03:47:36 +02:00
|
|
|
<div class="_title" v-else>{{ $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">
|
2020-12-26 03:47:36 +02:00
|
|
|
<MkButton @click="deny" inline>{{ $ts.cancel }}</MkButton>
|
|
|
|
<MkButton @click="accept" inline primary>{{ $ts.accept }}</MkButton>
|
2020-03-28 04:24:37 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="signin" v-else>
|
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';
|
|
|
|
import MkSignin from '@/components/signin.vue';
|
|
|
|
import MkButton from '@/components/ui/button.vue';
|
|
|
|
import * as os from '@/os';
|
2020-12-19 03:55:52 +02:00
|
|
|
import { login } from '@/account';
|
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,
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
state: null
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
session(): string {
|
|
|
|
return this.$route.params.session;
|
|
|
|
},
|
|
|
|
callback(): string {
|
|
|
|
return this.$route.query.callback;
|
|
|
|
},
|
|
|
|
name(): string {
|
|
|
|
return this.$route.query.name;
|
|
|
|
},
|
2020-03-28 11:33:24 +02:00
|
|
|
icon(): string {
|
|
|
|
return this.$route.query.icon;
|
|
|
|
},
|
2020-03-29 11:04:22 +03:00
|
|
|
permission(): string[] {
|
|
|
|
return this.$route.query.permission ? this.$route.query.permission.split(',') : [];
|
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) {
|
|
|
|
location.href = `${this.callback}?session=${this.session}`;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
deny() {
|
|
|
|
this.state = 'denied';
|
|
|
|
},
|
|
|
|
onLogin(res) {
|
2020-12-19 03:55:52 +02:00
|
|
|
login(res.i);
|
2020-03-28 04:24:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
|
|
</style>
|