settings.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * Settings: online admin password change (rewrites config/credentials.php).
  4. */
  5. require dirname(__DIR__) . '/app/bootstrap.php';
  6. auth_require();
  7. if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  8. csrf_verify();
  9. $new = (string)($_POST['new_password'] ?? '');
  10. if ($new !== (string)($_POST['new_password2'] ?? '')) {
  11. flash_set('New passwords do not match.', 'error');
  12. } else {
  13. $err = auth_change_password((string)($_POST['current_password'] ?? ''), $new);
  14. flash_set($err ?? 'Password changed.', $err ? 'error' : 'ok');
  15. }
  16. redirect('settings.php');
  17. }
  18. admin_header('Settings', 'settings');
  19. flash_render();
  20. ?>
  21. <h1>Settings</h1>
  22. <form method="post" class="card" style="max-width:26rem">
  23. <?= csrf_field() ?>
  24. <h2 style="margin-top:0">Change password</h2>
  25. <label for="c">Current password</label>
  26. <input type="password" id="c" name="current_password" autocomplete="current-password">
  27. <label for="n1">New password</label>
  28. <input type="password" id="n1" name="new_password" autocomplete="new-password">
  29. <label for="n2">Repeat new password</label>
  30. <input type="password" id="n2" name="new_password2" autocomplete="new-password">
  31. <p class="help">At least 8 characters. Written to config/credentials.php.</p>
  32. <button type="submit">Change password</button>
  33. </form>
  34. <p class="help">
  35. Username and S3 settings are edited directly in the files under <code>config/</code>.
  36. </p>
  37. <?php admin_footer(); ?>