Added link sharing #30

Merged
konrad merged 13 commits from feature/link-share into master 2019-09-09 17:55:44 +00:00
3 changed files with 61 additions and 2 deletions
Showing only changes of commit b8e524101a - Show all commits

View File

@ -7,7 +7,8 @@ export default {
user: {
authenticated: false,
infos: {}
infos: {},
isLinkShareAuth: false,
},
login(context, creds, redirect) {
@ -74,6 +75,17 @@ export default {
this.user.authenticated = false
},
async linkShareAuth(context, hash) {
HTTP.post('/shares/'+hash+'/auth')
.then(r => {
localStorage.setItem('token', r.data.token)
this.user.isLinkShareAuth = true
return Promise.resolve(r)
}).catch(e => {
return Promise.reject(e)
})
},
checkAuth() {
let jwt = localStorage.getItem('token')
this.getUserInfos()

View File

@ -0,0 +1,41 @@
<template>
<div class="message is-info" v-if="loading">
Authenticating...
</div>
</template>
<script>
import auth from '../../auth'
import message from '../../message'
export default {
name: 'linkSharingAuth',
data() {
return {
hash: '',
loading: true,
}
},
created() {
this.auth()
},
methods: {
auth() {
auth.linkShareAuth(this, this.$route.params.share)
.then(r => {
this.loading = false
// TODO: redirect
// eslint-disable-next-line
console.log(r)
})
.catch(e => {
message.error(e, this)
})
}
},
}
</script>
<style scoped>
</style>

View File

@ -12,6 +12,7 @@ import ShowListComponent from '@/components/lists/ShowList'
import NewListComponent from '@/components/lists/NewList'
import EditListComponent from '@/components/lists/EditList'
import ShowTasksInRangeComponent from '@/components/tasks/ShowTasksInRange'
import LinkShareAuthComponent from '@/components/sharing/linkSharingAuth'
// Namespace Handling
import NewNamespaceComponent from '@/components/namespaces/NewNamespace'
import EditNamespaceComponent from '@/components/namespaces/EditNamespace'
@ -106,6 +107,11 @@ export default new Router({
path: '/labels',
name: 'listLabels',
component: ListLabelsComponent
}
},
{
path: '/share/:share/auth',
name: 'linkShareAuth',
component: LinkShareAuthComponent
},
]
})