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
46 changes: 41 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,21 @@ This library exports a function that displays a password confirmation dialog whe

## Versions compatibility

Nextcloud | @nextcloud/vue | @nextcloud/password-confirmation
------------|----------------|---------------------------------
28.x | 8.x | 5.x
25.x - 27.x | 7.x | 2.x - 4.x
< 25.x | - | 1.x
| 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
```sh
npm add @nextcloud/password-confirmation
```

## Usage

### Direct usage

```js
import { confirmPassword } from '@nextcloud/password-confirmation'
import '@nextcloud/password-confirmation/style.css' // Required for dialog styles
Expand All @@ -42,6 +45,30 @@ const foo = async () => {
}
```

### Usage with axios interceptor

```js
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
```ts
/**
Expand All @@ -62,6 +89,15 @@ declare function isPasswordConfirmationRequired(): boolean
* 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
Expand Down
4 changes: 4 additions & 0 deletions src/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
* SPDX-License-Identifier: MIT
*/

/**
* Lax: Confirm password if needed.
* Strict: Confirm in the request.
*/
export enum PwdConfirmationMode {
Lax = 'lax',
Strict = 'strict',
Expand Down
Loading