@nextcloud/password-confirmation
v5.3.2
Published
Password confirmation for Nextcloud
Keywords
Readme
@nextcloud/password-confirmation
Promise-based password confirmation for Nextcloud.
This library exports a function that displays a password confirmation dialog when called and returns a promise. This makes it easier to integrate with other asynchronous operations.
Versions compatibility
| Nextcloud | @nextcloud/vue | @nextcloud/password-confirmation | | ----------- | -------------- | -------------------------------- | | 28+ | 8.x | 5.x | | 25.x - 27.x | 7.x | 2.x - 4.x | | < 25.x | - | 1.x |
Installation
npm add @nextcloud/password-confirmationUsage
Direct usage
import { confirmPassword } from '@nextcloud/password-confirmation'
import '@nextcloud/password-confirmation/style.css' // Required for dialog styles
const foo = async () => {
try {
await confirmPassword()
// Your logic
} catch (error) {
// Your error handling logic
}
}Usage with axios interceptor
import axios from '@nextcloud/axios'
import { addPasswordConfirmationInterceptors, PwdConfirmationMode } from '@nextcloud/password-confirmation'
import '@nextcloud/password-confirmation/style.css' // Required for dialog styles
addPasswordConfirmationInterceptors(axios)
const foo = async () => {
try {
const response = await axios.request({
confirmPassword: PwdConfirmationMode.Strict,
method,
url,
data: this.getData(),
})
// Your logic
} catch (error) {
// Your error handling logic
}
}API Reference
/**
* Check if password confirmation is required according to the last confirmation time.
* Use as a replacement of deprecated `OC.PasswordConfirmation.requiresPasswordConfirmation()`.
* Not needed if `confirmPassword()` can be used, because it checks requirements itself.
*
* @return {boolean} Whether password confirmation is required or was confirmed recently
*/
declare function isPasswordConfirmationRequired(): boolean
/**
* Confirm password if needed.
* Replacement of deprecated `OC.PasswordConfirmation.requirePasswordConfirmation(callback)`
*
* @return {Promise<void>} Promise that resolves when password is confirmed or not needded.
* Rejects if password confirmation was cancelled
* or confirmation is already in process.
*/
declare function confirmPassword(): Promise<void>
/**
* Lax: Confirm password if needed.
* Strict: Confirm in the request.
*/
export enum PwdConfirmationMode {
Lax = 'lax',
Strict = 'strict',
}Releasing
- Create release branch
- Adjust version using
npm version vx.y.z --no-git-tag-version - Update
CHANGELOG.md - Commit and open PR
- After merge, pull latest main
git tag vx.y.zgit push origin vx.y.znpm ci && npm run build && npm publish
