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