2018-03-08 09:41:39 +01:00
|
|
|
<template>
|
|
|
|
<div id="authorize">
|
2018-07-10 18:13:50 +02:00
|
|
|
<div>
|
|
|
|
<el-header>
|
|
|
|
<el-row>
|
|
|
|
<el-col :span="24" class="close">
|
|
|
|
<el-button type="text" icon="el-icon-close" @click="close" class="close-button">
|
|
|
|
</el-button>
|
|
|
|
</el-col>
|
|
|
|
</el-row>
|
|
|
|
</el-header>
|
|
|
|
<el-main>
|
|
|
|
<div class="authorization-url">
|
|
|
|
<p>Now authorization page is opened in your browser.</p>
|
|
|
|
<p>If it is not opened, please open the following URL manually.</p>
|
|
|
|
<p class="url">{{ $route.query.url }}</p>
|
|
|
|
</div>
|
|
|
|
<el-form ref="form" :model="authorizeForm" label-width="120px" label-position="top" class="authorize-form" v-on:submit.prevent="authorizeSubmit">
|
|
|
|
<el-form-item label="Please paste authorization code from your browser:">
|
|
|
|
<el-input v-model="authorizeForm.code"></el-input>
|
|
|
|
</el-form-item>
|
|
|
|
<!-- Dummy form to guard submitting with enter -->
|
|
|
|
<el-form-item class="hidden">
|
|
|
|
<el-input></el-input>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item class="submit">
|
|
|
|
<el-button
|
|
|
|
type="primary"
|
|
|
|
@click="authorizeSubmit"
|
|
|
|
v-loading="submitting"
|
|
|
|
element-loading-background="rgba(0, 0, 0, 0.8)">
|
|
|
|
Submit
|
|
|
|
</el-button>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
</el-main>
|
|
|
|
</div>
|
2018-03-08 09:41:39 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
name: 'authorize',
|
2018-07-10 18:13:50 +02:00
|
|
|
props: {
|
|
|
|
url: {
|
|
|
|
type: String,
|
|
|
|
default: ''
|
|
|
|
}
|
|
|
|
},
|
2018-03-08 09:41:39 +01:00
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
authorizeForm: {
|
|
|
|
code: ''
|
2018-06-12 01:48:01 +02:00
|
|
|
},
|
|
|
|
submitting: false
|
2018-03-08 09:41:39 +01:00
|
|
|
}
|
|
|
|
},
|
2018-07-10 18:13:50 +02:00
|
|
|
mounted () {
|
|
|
|
console.log(this.url)
|
|
|
|
},
|
2018-03-08 09:41:39 +01:00
|
|
|
methods: {
|
|
|
|
authorizeSubmit () {
|
2018-06-12 01:48:01 +02:00
|
|
|
this.submitting = true
|
2018-03-08 09:41:39 +01:00
|
|
|
this.$store.dispatch('Authorize/submit', this.authorizeForm.code)
|
2018-06-12 01:48:01 +02:00
|
|
|
.finally(() => {
|
|
|
|
this.submitting = false
|
|
|
|
})
|
2018-03-08 16:24:18 +01:00
|
|
|
.then((id) => {
|
2018-03-09 07:21:25 +01:00
|
|
|
this.$router.push({ path: `/${id}/home` })
|
2018-03-08 16:24:18 +01:00
|
|
|
})
|
2018-06-12 01:48:01 +02:00
|
|
|
.catch((err) => {
|
|
|
|
if (err.name === 'DuplicateRecordError') {
|
|
|
|
this.$message({
|
2018-08-13 08:27:53 +02:00
|
|
|
message: this.$t('message.authorize_duplicate_error'),
|
2018-06-12 01:48:01 +02:00
|
|
|
type: 'error'
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
this.$message({
|
2018-08-13 08:27:53 +02:00
|
|
|
message: this.$t('message.authorize_error'),
|
2018-06-12 01:48:01 +02:00
|
|
|
type: 'error'
|
|
|
|
})
|
|
|
|
}
|
2018-03-13 14:25:31 +01:00
|
|
|
})
|
2018-03-20 14:12:06 +01:00
|
|
|
},
|
|
|
|
close () {
|
|
|
|
return this.$router.push({ path: '/' })
|
2018-03-08 09:41:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2018-04-01 05:10:54 +02:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
#authorize /deep/ {
|
2018-03-10 15:11:27 +01:00
|
|
|
background-color: #292f3f;
|
|
|
|
color: #ffffff;
|
2018-03-08 09:41:39 +01:00
|
|
|
text-align: center;
|
2018-04-01 05:10:54 +02:00
|
|
|
min-height: 100%;
|
2018-03-10 15:11:27 +01:00
|
|
|
|
2018-03-20 14:58:50 +01:00
|
|
|
.close {
|
|
|
|
text-align: right;
|
2018-04-04 13:11:33 +02:00
|
|
|
|
|
|
|
.close-button {
|
|
|
|
font-size: 24px;
|
|
|
|
}
|
2018-03-20 14:58:50 +01:00
|
|
|
}
|
|
|
|
|
2018-07-10 18:13:50 +02:00
|
|
|
.authorization-url {
|
|
|
|
margin: 0 auto 64px;
|
|
|
|
max-width: 80%;
|
|
|
|
|
|
|
|
.url {
|
|
|
|
color: #909399;
|
|
|
|
word-wrap: break-word;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-10 15:11:27 +01:00
|
|
|
.authorize-form {
|
|
|
|
width: 500px;
|
|
|
|
margin: 0 auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
.el-form-item__label {
|
|
|
|
color: #f0f3f9;
|
|
|
|
}
|
|
|
|
|
|
|
|
.el-input__inner {
|
|
|
|
background-color: #373d48;
|
|
|
|
color: #ffffff;
|
|
|
|
border: 0;
|
|
|
|
}
|
2018-03-22 07:17:31 +01:00
|
|
|
|
|
|
|
.hidden {
|
|
|
|
display: none;
|
|
|
|
}
|
2018-03-08 09:41:39 +01:00
|
|
|
}
|
|
|
|
</style>
|