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

Fix password banned error not shown #10145

Merged
merged 2 commits into from
Dec 11, 2023
Merged
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
1 change: 1 addition & 0 deletions changelog/unreleased/enhancement-create-link-modal
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ Enhancement: Create link modal
When creating a link while passwords are enfoced, Web will now display a modal that lets the user not only set a password, but also the role and an optional expiration date.

https://github.com/owncloud/web/pull/10104
https://github.com/owncloud/web/pull/10145
24 changes: 19 additions & 5 deletions packages/web-pkg/src/components/CreateLinkModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@
appearance="outline"
variation="passive"
@click="cancel"
>{{ $gettext('Cancel') }}</oc-button
>
>{{ $gettext('Cancel') }}
</oc-button>
<oc-button
class="link-modal-confirm oc-modal-body-actions-confirm oc-ml-s"
appearance="filled"
variation="primary"
@click="confirm"
>{{ $gettext('Share') }}</oc-button
>
>{{ $gettext('Share') }}
</oc-button>
</div>
</template>

Expand Down Expand Up @@ -306,15 +306,29 @@ export default defineComponent({
)
}

let userFacingErrors = []
const failed = result.filter(({ status }) => status === 'rejected')
if (failed.length) {
;(failed as PromiseRejectedResult[]).map(({ reason }) => reason).forEach(console.error)
;(failed as PromiseRejectedResult[])
.map(({ reason }) => reason)
.forEach((e) => {
console.error(e)
// Human-readable error message is provided, for example when password is on banned list
if (e.statusCode === 400) {
userFacingErrors.push(e)
}
})
}

if (props.callbackFn) {
props.callbackFn(result)
}

if (userFacingErrors.length) {
password.error = $gettext(userFacingErrors[0].message)
return
}

return store.dispatch('hideModal')
}

Expand Down