fix(sharing): show common confirmation on password reset

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
Ferdinand Thiessen 2026-03-28 13:21:02 +01:00
parent b6b24abed5
commit 43947d7014
No known key found for this signature in database
GPG key ID: 7E849AE05218500F
2 changed files with 16 additions and 15 deletions

View file

@ -21,7 +21,7 @@ import NcPasswordField from '@nextcloud/vue/components/NcPasswordField'
const publicShareAuth = loadState<{
canResendPassword: boolean
shareType: ShareType
identityOk?: boolean | null
showPasswordReset?: boolean
invalidPassword?: boolean
}>('core', 'publicShareAuth')
@ -29,8 +29,8 @@ const requestToken = getRequestToken()
const sharingToken = getSharingToken()
const { shareType, invalidPassword, canResendPassword } = publicShareAuth
const hasIdentityCheck = typeof publicShareAuth.identityOk === 'boolean'
const showIdentityCheck = ref(typeof publicShareAuth.identityOk === 'boolean')
const isPasswordResetProcessed = !!publicShareAuth.showPasswordReset
const showPasswordReset = ref(publicShareAuth.showPasswordReset ?? false)
const password = ref('')
const email = ref('')
@ -48,7 +48,7 @@ onMounted(() => {
<NcGuestContent :class="$style.publicShareAuth">
<h2>{{ t('core', 'This share is password-protected') }}</h2>
<form
v-show="!showIdentityCheck"
v-show="!showPasswordReset"
:class="$style.publicShareAuth__form"
method="POST">
<NcNoteCard v-if="invalidPassword" type="error">
@ -74,15 +74,14 @@ onMounted(() => {
</form>
<form
v-if="showIdentityCheck"
v-if="showPasswordReset"
:class="$style.publicShareAuth__form"
method="POST">
<NcNoteCard v-if="!hasIdentityCheck" type="info">
{{ t('core', 'Please type in your email address to request a temporary password') }}
</NcNoteCard>
<NcNoteCard v-else :type="publicShareAuth.identityOk ? 'success' : 'error'">
{{ publicShareAuth.identityOk ? t('core', 'Password sent!') : t('core', 'You are not authorized to request a password for this share') }}
<NcNoteCard type="info">
{{ isPasswordResetProcessed
? t('core', 'If the email address was correct then you will receive an email with the password.')
: t('core', 'Please type in your email address to request a temporary password')
}}
</NcNoteCard>
<NcTextField
@ -96,7 +95,7 @@ onMounted(() => {
<input type="hidden" name="passwordRequest" value="">
<NcFormBox row>
<NcButton wide @click="showIdentityCheck = false">
<NcButton wide @click="showPasswordReset = false">
{{ t('core', 'Back') }}
</NcButton>
<NcButton type="submit" variant="primary" wide>
@ -107,10 +106,10 @@ onMounted(() => {
<!-- request password button -->
<NcButton
v-if="canResendPassword && !showIdentityCheck"
v-if="canResendPassword && !showPasswordReset"
:class="$style.publicShareAuth__forgotPasswordButton"
wide
@click="showIdentityCheck = true">
@click="showPasswordReset = true">
{{ t('core', 'Forgot password') }}
</NcButton>
</NcGuestContent>

View file

@ -9,10 +9,12 @@
\OCP\Util::addStyle('core', 'guest');
\OCP\Util::addScript('core', 'public_share_auth');
$showPasswordReset = isset($_['identityOk']) && $_['identityOk'] !== null;
$initialState = \OCP\Server::get(\OCP\IInitialStateService::class);
$initialState->provideInitialState('files_sharing', 'sharingToken', $_['share']->getToken());
$initialState->provideInitialState('core', 'publicShareAuth', [
'identityOk' => $_['identityOk'] ?? null,
// if the password reset was processed (not caring about result)
'showPasswordReset' => $showPasswordReset,
'shareType' => $_['share']->getShareType(),
'invalidPassword' => $_['wrongpw'] ?? null,
'canResendPassword' => $_['share']->getShareType() === \OCP\Share\IShare::TYPE_EMAIL && !$_['share']->getSendPasswordByTalk(),