Skip to content
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
51 changes: 36 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"bugs": "https://github.com/nextcloud-libraries/nextcloud-password-confirmation/issues",
"license": "MIT",
"dependencies": {
"@nextcloud/auth": "^2.4.0",
"@nextcloud/axios": "^2.5.0",
"@nextcloud/l10n": "^3.1.0",
"@nextcloud/router": "^3.0.1"
Expand Down
15 changes: 9 additions & 6 deletions src/components/PasswordDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<NcButton class="vue-password-confirmation__submit"
type="primary"
native-type="submit"
:disabled="!password">
:disabled="!password || loading">
<template v-if="loading" #icon>
<NcLoadingIcon :size="20" />
</template>
Expand All @@ -32,12 +32,10 @@
</template>

<script lang="ts">
import axios from '@nextcloud/axios'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcDialog from '@nextcloud/vue/dist/Components/NcDialog.js'
import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
import NcPasswordField from '@nextcloud/vue/dist/Components/NcPasswordField.js'
import { generateUrl } from '@nextcloud/router'
import { defineComponent } from 'vue'
import { DIALOG_ID } from '../globals.js'
import { t } from '../utils/l10n.js'
Expand All @@ -59,6 +57,13 @@ export default defineComponent({
NcPasswordField,
},

props: {
validate: {
type: Function,
default: () => {},
},
},

setup() {
// non reactive props
return {
Expand Down Expand Up @@ -102,10 +107,8 @@ export default defineComponent({
return
}

const url = generateUrl('/login/confirm')
try {
const { data } = await axios.post(url, { password: this.password })
window.nc_lastLogin = data.lastLogin
await this.validate(this.password)
this.$emit('confirmed')
} catch (e) {
this.showError = true
Expand Down
18 changes: 18 additions & 0 deletions src/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,21 @@

export const DIALOG_ID = 'password-confirmation-dialog'
export const MODAL_CLASS = 'modal-mask' // NcModal component root class https://github.com/nextcloud/nextcloud-vue/blob/v7.0.0-beta.2/src/components/NcModal/NcModal.vue

export enum PwdConfirmationMode {
Lax = 'lax',
Strict = 'strict',
}

declare module '@nextcloud/axios' {
export interface AxiosRequestConfig {
/** To use this property you need to use the addPasswordConfirmationInterceptors function. */
confirmPassword?: PwdConfirmationMode;
}
}

declare global {
interface Window {
_nc_password_confirmation_dialog?: Vue
}
}
Loading