Skip to content

Commit

Permalink
Merge pull request #1900 from owncloud/bugfix/private-link-redirectio…
Browse files Browse the repository at this point in the history
…n-after-login

Redirect to private link after log in
Vincent Petry authored Sep 13, 2019
2 parents ccc819e + 63e79f7 commit 3deea60
Showing 6 changed files with 59 additions and 16 deletions.
15 changes: 7 additions & 8 deletions apps/files/src/components/FileList.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="uk-height-1-1">
<div class="uk-flex uk-flex-column uk-height-1-1">
<div class="uk-overflow-auto uk-flex-auto">
<div id="files-list-container" class="uk-overflow-auto uk-flex-auto">
<oc-table middle divider class="oc-filelist uk-margin-remove-bottom" id="files-list" v-show="!loadingFolder">
<thead>
<oc-table-row>
@@ -146,19 +146,18 @@ export default {
absolutePath = !this.item ? this.configuration.rootFolder : this.item
}
const self = this
this.loadFolder({
client: this.$client,
absolutePath: absolutePath,
$gettext: this.$gettext,
routeName: this.$route.name
}).then(() => {
const scrollTo = self.$route.query.scrollTo
if (scrollTo) {
self.$nextTick(() => {
self.setHighlightedFile(scrollTo)
const file = self.highlightedFile
self.$scrollTo(`#file-row-${file.id}`, 500, {
const scrollTo = this.$route.query.scrollTo
if (scrollTo && this.activeFiles.length > 0) {
this.$nextTick(() => {
const file = this.activeFiles.find(item => item.name === scrollTo)
this.setHighlightedFile(file)
this.$scrollTo(`#file-row-${file.id}`, 500, {
container: '#files-list-container'
})
})
15 changes: 12 additions & 3 deletions apps/files/src/components/FilesApp.vue
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
<div id="files">
<files-app-bar />
<oc-grid class="uk-height-1-1" oc-scroll-offset=".oc-app-bar">
<div class="uk-width-expand uk-overflow-auto uk-height-1-1" @dragover="$_ocApp_dragOver" :class="{ 'uk-visible@m' : _sidebarOpen }" id="files-list-container">
<div class="uk-width-expand uk-overflow-auto uk-height-1-1" @dragover="$_ocApp_dragOver" :class="{ 'uk-visible@m' : _sidebarOpen }">
<oc-loader id="files-list-progress" v-if="loadingFolder"></oc-loader>
<trash-bin v-if="$route.name === 'files-trashbin'" :fileData="activeFiles" />
<SharedFilesList v-else-if="sharedList" @toggle="toggleFileSelect" :fileData="activeFiles" />
@@ -53,7 +53,7 @@ export default {
},
methods: {
...mapActions('Files', ['resetFileSelection', 'addFileSelection', 'removeFileSelection', 'dragOver', 'setHighlightedFile', 'toggleFileSelect']),
...mapActions(['openFile', 'showMessage']),
...mapActions(['openFile', 'showMessage', 'setPrivateLinkUrlPath']),
trace () {
console.info('trace', arguments)
@@ -122,7 +122,7 @@ export default {
computed: {
...mapGetters('Files', ['selectedFiles', 'activeFiles', 'dropzone', 'loadingFolder', 'highlightedFile']),
...mapGetters(['extensions']),
...mapGetters(['extensions', 'privateLinkUrlPath']),
_sidebarOpen () {
return this.highlightedFile !== null
@@ -136,6 +136,15 @@ export default {
$route () {
this.setHighlightedFile(null)
}
},
beforeMount () {
// Redirect to private link after authorization
if (this.privateLinkUrlPath) {
this.$router.push(this.privateLinkUrlPath)
// Resets private link path in store
// Needed due to persistance of that state
this.setPrivateLinkUrlPath(null)
}
}
}
</script>
2 changes: 1 addition & 1 deletion apps/files/src/components/FilesAppBar.vue
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
<div class="uk-width-expand">
<oc-breadcrumb id="files-breadcrumb" :items="breadcrumbs" v-if="showBreadcrumb" home></oc-breadcrumb>
<span class="uk-flex uk-flex-middle" v-if="!showBreadcrumb">
<oc-icon :name="pageIcon" class="uk-margin-small-right"></oc-icon>
<oc-icon v-if="pageIcon" :name="pageIcon" class="uk-margin-small-right" />
<span class="uk-text-lead">{{pageTitle}}</span>
</span>
</div>
5 changes: 4 additions & 1 deletion src/router/index.js
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ const router = new Router({
path: '/f/:fileId',
name: 'privateLink',
redirect: '/files/private-link/:fileId',
meta: { auth: false, hideHeadbar: true }
meta: { hideHeadbar: true }
},
{
path: '/s/:token',
@@ -66,6 +66,9 @@ const router = new Router({
})

router.beforeEach(function (to, from, next) {
if (to.name === 'private-link') {
store.dispatch('setPrivateLinkUrlPath', to.path)
}
let authRequired = true
if (to.meta.auth === false) {
authRequired = false
8 changes: 5 additions & 3 deletions src/store/index.js
Original file line number Diff line number Diff line change
@@ -8,14 +8,15 @@ import app from './app'
import apps from './apps'
import config from './config'
import user from './user'
import links from './links'

Vue.use(Vuex)

const vuexPersist = new VuexPersistence({
key: 'phoenixState',
storage: window.localStorage,
filter: (mutation) => (['SET_USER', 'SET_TOKEN'].indexOf(mutation.type) > -1),
modules: ['user']
filter: (mutation) => (['SET_USER', 'SET_TOKEN', 'SET_PRIVATE_LINK_URL_PATH'].indexOf(mutation.type) > -1),
modules: ['user', 'links']
})

const strict = process.env.NODE_ENV === 'development'
@@ -29,7 +30,8 @@ export const Store = new Vuex.Store({
app,
apps,
user,
config
config,
links
},
strict
})
30 changes: 30 additions & 0 deletions src/store/links.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const state = {
/**
* Private link path in case user needs to log in first
* @return {string} path to the file/folder
*/
privateLinkUrlPath: null
}

const actions = {
setPrivateLinkUrlPath ({ commit }, path) {
commit('SET_PRIVATE_LINK_URL_PATH', path)
}
}

const mutations = {
SET_PRIVATE_LINK_URL_PATH (state, path) {
state.privateLinkUrlPath = path
}
}

const getters = {
privateLinkUrlPath: state => state.privateLinkUrlPath
}

export default {
state,
actions,
mutations,
getters
}

0 comments on commit 3deea60

Please sign in to comment.