diff --git a/core/src/main.js b/core/src/main.js index 1e481bf877df7..ea49eb7ac69bd 100644 --- a/core/src/main.js +++ b/core/src/main.js @@ -37,6 +37,8 @@ import './globals.js' import './jquery/index.js' import { initCore } from './init.js' import { getRequestToken } from '@nextcloud/auth' +import { generateUrl } from '@nextcloud/router' +import Axios from '@nextcloud/axios' // eslint-disable-next-line camelcase __webpack_nonce__ = btoa(getRequestToken()) @@ -52,3 +54,20 @@ window.addEventListener('DOMContentLoaded', function() { $(window).on('hashchange', _.bind(OC.Util.History._onPopState, OC.Util.History)) } }) + +// Fix error "CSRF check failed" +document.addEventListener('DOMContentLoaded', function() { + const form = document.getElementById('password-input-form') + if (form) { + form.addEventListener('submit', async function(event) { + event.preventDefault() + const requestToken = document.getElementById('requesttoken') + if (requestToken) { + const url = generateUrl('/csrftoken') + const resp = await Axios.get(url) + requestToken.value = resp.data.token + } + form.submit() + }) + } +}) diff --git a/core/templates/publicshareauth.php b/core/templates/publicshareauth.php index 516795852b29f..e54018b5a90b5 100644 --- a/core/templates/publicshareauth.php +++ b/core/templates/publicshareauth.php @@ -22,7 +22,7 @@
- +
- + - + getShareType() === $_['share']::TYPE_EMAIL && !$_['share']->getSendPasswordByTalk()): ?> t('Forgot password?')); ?> - +