2019-09-09 17:55:43 +00:00
|
|
|
<template>
|
2021-04-11 13:18:19 +00:00
|
|
|
<div>
|
|
|
|
<div class="notification is-info is-light has-text-centered" v-if="loading">
|
2021-06-23 23:24:57 +00:00
|
|
|
{{ $t('sharing.authenticating') }}
|
2021-04-11 13:18:19 +00:00
|
|
|
</div>
|
|
|
|
<div v-if="authenticateWithPassword" class="box">
|
|
|
|
<p class="pb-2">
|
2021-06-23 23:24:57 +00:00
|
|
|
{{ $t('sharing.passwordRequired') }}
|
2019-11-03 12:44:40 +00:00
|
|
|
</p>
|
2021-04-11 13:18:19 +00:00
|
|
|
<div class="field">
|
|
|
|
<div class="control">
|
|
|
|
<input
|
|
|
|
id="linkSharePassword"
|
|
|
|
type="password"
|
|
|
|
class="input"
|
2021-06-23 23:24:57 +00:00
|
|
|
:placeholder="$t('user.auth.passwordPlaceholder')"
|
2021-04-11 13:18:19 +00:00
|
|
|
v-model="password"
|
|
|
|
v-focus
|
|
|
|
@keyup.enter.prevent="auth"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<x-button @click="auth" :loading="loading">
|
2021-06-23 23:24:57 +00:00
|
|
|
{{ $t('user.auth.login') }}
|
2021-04-11 13:18:19 +00:00
|
|
|
</x-button>
|
|
|
|
|
2021-07-09 17:10:25 +00:00
|
|
|
<div class="notification is-danger mt-4" v-if="errorMessage !== ''">
|
|
|
|
{{ errorMessage }}
|
2021-04-11 13:18:19 +00:00
|
|
|
</div>
|
2019-11-03 12:44:40 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2019-09-09 17:55:43 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-09-10 13:04:00 +00:00
|
|
|
import {mapGetters} from 'vuex'
|
2019-09-09 17:55:43 +00:00
|
|
|
|
2020-09-05 20:35:52 +00:00
|
|
|
export default {
|
|
|
|
name: 'LinkSharingAuth',
|
|
|
|
data() {
|
|
|
|
return {
|
2021-04-11 13:18:19 +00:00
|
|
|
loading: true,
|
|
|
|
authenticateWithPassword: false,
|
2021-07-09 17:10:25 +00:00
|
|
|
errorMessage: '',
|
2021-04-11 13:18:19 +00:00
|
|
|
|
2020-09-05 20:35:52 +00:00
|
|
|
hash: '',
|
2021-04-11 13:18:19 +00:00
|
|
|
password: '',
|
2020-09-05 20:35:52 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.auth()
|
|
|
|
},
|
|
|
|
mounted() {
|
2021-06-23 23:24:57 +00:00
|
|
|
this.setTitle(this.$t('sharing.authenticating'))
|
2020-09-05 20:35:52 +00:00
|
|
|
},
|
2021-09-10 13:04:00 +00:00
|
|
|
computed: mapGetters('auth', [
|
|
|
|
'authLinkShare',
|
|
|
|
]),
|
2020-09-05 20:35:52 +00:00
|
|
|
methods: {
|
|
|
|
auth() {
|
2021-07-09 17:10:25 +00:00
|
|
|
this.errorMessage = ''
|
2021-04-11 13:18:19 +00:00
|
|
|
|
2021-04-09 14:29:07 +00:00
|
|
|
if (this.authLinkShare) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-04-11 13:18:19 +00:00
|
|
|
this.loading = true
|
|
|
|
|
|
|
|
this.$store.dispatch('auth/linkShareAuth', {hash: this.$route.params.share, password: this.password})
|
2020-09-05 20:35:52 +00:00
|
|
|
.then((r) => {
|
2021-04-09 14:29:07 +00:00
|
|
|
this.$router.push({name: 'list.list', params: {listId: r.list_id}})
|
2020-09-05 20:35:52 +00:00
|
|
|
})
|
|
|
|
.catch(e => {
|
2021-04-11 13:18:19 +00:00
|
|
|
if (typeof e.response.data.code !== 'undefined' && e.response.data.code === 13001) {
|
|
|
|
this.authenticateWithPassword = true
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-07-09 17:10:25 +00:00
|
|
|
// TODO: Put this logic in a global errorMessage handler method which checks all auth codes
|
|
|
|
let errorMessage = this.$t('sharing.errorMessage')
|
2021-04-11 13:18:19 +00:00
|
|
|
if (e.response && e.response.data && e.response.data.message) {
|
2021-07-09 17:10:25 +00:00
|
|
|
errorMessage = e.response.data.message
|
2021-04-11 13:18:19 +00:00
|
|
|
}
|
|
|
|
if (typeof e.response.data.code !== 'undefined' && e.response.data.code === 13002) {
|
2021-07-09 17:10:25 +00:00
|
|
|
errorMessage = this.$t('sharing.invalidPassword')
|
2021-04-11 13:18:19 +00:00
|
|
|
}
|
2021-07-09 17:10:25 +00:00
|
|
|
this.errorMessage = errorMessage
|
2021-04-11 13:18:19 +00:00
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
this.loading = false
|
2020-09-05 20:35:52 +00:00
|
|
|
})
|
2019-11-03 12:44:40 +00:00
|
|
|
},
|
2020-09-05 20:35:52 +00:00
|
|
|
},
|
|
|
|
}
|
2019-09-09 17:55:43 +00:00
|
|
|
</script>
|