Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remember public link password on refresh #4083

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions apps/files/src/components/PublicLinks/PublicLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default {
firstTime: true,
passwordRequired: false,
password: null,
savedPassword: null,
inputErrorMessage: null
}
},
Expand All @@ -72,11 +73,23 @@ export default {
}
},
mounted() {
const publicLinkPassword = sessionStorage.getItem('publicLinkInfo')
if (publicLinkPassword) {
try {
this.savedPassword = atob(publicLinkPassword)
} catch (e) {
console.error('Error decoding saved password, ignoring', e)
// ignore
this.savedPassword = null
}
}

this.resolvePublicLink()
},
methods: {
...mapActions('Files', ['setPublicLinkPassword']),
resolvePublicLink() {
const password = this.savedPassword || this.password
this.loading = true
this.inputErrorMessage = null
const properties = this.davProperties.concat([
Expand All @@ -87,10 +100,10 @@ export default {
this.$client.publicFiles.PUBLIC_LINK_SHARE_OWNER
])
this.$client.publicFiles
.list(this.$route.params.token, this.password, properties, '0')
.list(this.$route.params.token, password, properties, '0')
.then(files => {
this.passwordRequired = false
this.setPublicLinkPassword(this.password)
this.setPublicLinkPassword(password)
if (files[0].getProperty(this.$client.publicFiles.PUBLIC_LINK_PERMISSION) === '4') {
this.$router.push({
name: 'public-files-drop',
Expand All @@ -108,6 +121,9 @@ export default {
})
})
.catch(error => {
// only attempt once with saved password, it might have changed
// we don't want to populate the form with it!
this.savedPassword = null
if (error.statusCode === 401) {
this.passwordRequired = true
if (!this.firstTime) {
Expand Down
5 changes: 5 additions & 0 deletions apps/files/src/store/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ export default {
},
SET_PUBLIC_LINK_PASSWORD(state, password) {
state.publicLinkPassword = password
if (password) {
sessionStorage.setItem('publicLinkInfo', btoa(password))
} else {
sessionStorage.removeItem('publicLinkInfo')
}
},

ADD_ACTION_TO_PROGRESS(state, item) {
Expand Down
8 changes: 8 additions & 0 deletions changelog/unreleased/public-link-remember-password-on-refresh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Enhancement: Remember public link password on page refresh

When refreshing the page in the file list of a public link share,
the user doesn't need to enter the password again. This only applies for the current page
and the password is forgotten by the browser again upon closing or switching to another site.

https://github.com/owncloud/phoenix/pull/4083
https://github.com/owncloud/product/issues/231