# Passcode

Functions to manage passcode in the app.

> You'll need to import the javascript file in your website before starting from this [link](https://docs.webtonative.com/javascript-apis/getting-started).

## Set Passcode

Creates or updates a user's passcode with an optional reauthentication step.

{% tabs %}
{% tab title="Plain Javascript" %}

```javascript
window.WTN.Passcode.setPasscode({ reauthenticate: true });
```

{% endtab %}

{% tab title="ES5+" %}

```javascript
import { Passcode } from "webtonative";

Passcode.setPasscode({ reauthenticate: true });
```

{% endtab %}
{% endtabs %}

**Parameter:**

| Key              | Type      | Description                                                                                                                                                                   |
| ---------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `reauthenticate` | `Boolean` | If `true`, the user must enter their existing password before setting or changing the passcode. If `false`, the passcode can be set without asking for the existing password. |

When reauthentication is enabled, the function prompts for the current password before proceeding. Otherwise, it goes directly to passcode setup.

***

## Reset Passcode

Resets the user's passcode with optional app data cleanup.

{% tabs %}
{% tab title="Plain Javascript" %}

```javascript
window.WTN.Passcode.resetPasscode({ resetAppData: false });
```

{% endtab %}

{% tab title="ES5+" %}

```javascript
import { Passcode } from "webtonative";

Passcode.resetPasscode({ resetAppData: false });
```

{% endtab %}
{% endtabs %}

**Parameter:**

| Key            | Type      | Description                                                                                                                                                            |
| -------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `resetAppData` | `Boolean` | If `true`, all application data is cleared along with the passcode. If `false`, only the passcode-related data is cleared and the rest of the app data remains intact. |

Depending on the value of `resetAppData`, this either performs a full app data reset or limits the reset to passcode information only.
