Connector Open-Source Code

Browse connector files locally. Exchange API keys stay on your device.

ui/account.php

<?php
declare(strict_types=1);

require_once __DIR__ . '/common.php';

if (($_SERVER['REQUEST_METHOD'] ?? '') === 'POST') {
    $do = (string)($_POST['do'] ?? '');
    if ($do === 'change_password') {
        $current = (string)($_POST['current_password'] ?? '');
        $new1 = (string)($_POST['new_password'] ?? '');
        $new2 = (string)($_POST['confirm_password'] ?? '');

        if (!nv_ui_auth_verify($current)) {
            nv_toast_set('err', 'Current password is invalid.');
        } elseif (strlen($new1) < 8) {
            nv_toast_set('warn', 'New password must be at least 8 characters.');
        } elseif (!hash_equals($new1, $new2)) {
            nv_toast_set('err', 'New password and confirmation do not match.');
        } else {
            $err = null;
            if (nv_ui_auth_save_password($new1, $err)) {
                nv_toast_set('ok', 'Password updated successfully.');
            } else {
                nv_toast_set('err', $err ?: 'Failed to update password.');
            }
        }

        header('Location: ./index.php');
        exit;
    }
}

render_header('Security', 'Security', false);
?>

<div class="d-flex flex-wrap gap-2 mb-3">
  <a class="btn btn-soft" href="./index.php"><i class="bi bi-house me-1"></i>Home</a>
  <a class="btn btn-soft" href="./forgot_password.php"><i class="bi bi-key me-1"></i>Forgot password</a>
</div>

<div class="row g-3">
  <div class="col-12 col-lg-8" id="security">
    <div class="nv-card">
      <div class="nv-titlebar">
        <strong>Change password</strong>
      </div>
      <div class="nv-pad">
        <form method="post" autocomplete="off">
          <input type="hidden" name="do" value="change_password">
          <label class="form-label">Current password</label>
          <input type="password" name="current_password" class="form-control mb-3" required>

          <label class="form-label">New password</label>
          <input type="password" name="new_password" class="form-control mb-3" minlength="8" required>

          <label class="form-label">Confirm new password</label>
          <input type="password" name="confirm_password" class="form-control mb-3" minlength="8" required>

          <button class="btn btn-accent" type="submit">
            <i class="bi bi-shield-check me-1"></i>Update password
          </button>
        </form>
      </div>
    </div>
  </div>
</div>

<?php render_footer(); ?>