Skip to content
Open
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
27 changes: 13 additions & 14 deletions core/src/views/PublicShareAuth.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ import NcPasswordField from '@nextcloud/vue/components/NcPasswordField'
const publicShareAuth = loadState<{
canResendPassword: boolean
shareType: ShareType
identityOk?: boolean | null
showPasswordReset?: boolean
invalidPassword?: boolean
}>('core', 'publicShareAuth')

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('')

Expand All @@ -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">
Expand All @@ -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
Expand All @@ -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>
Expand All @@ -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>
Expand Down
4 changes: 3 additions & 1 deletion core/templates/publicshareauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
Loading