Files
itflow/post/misc.php
johnnyq fecd1cabff Credentials makeover: rebuilt credentials list with kind icons, username copy, password show/copy and live 2FA code buttons fetched on demand, where it opens, what it is for (asset, contact, vendors, licenses, services), password age pills and last used, filters for Starred, With 2FA, No 2FA, Not changed in 90 days and Shared with counts, search across notes, second link, tags, asset and contact, open straight to a credential with ?open=ID; new credential quick look with login, age, last viewed by, links with unlink, notes, open share links with turn off, and history; tabbed new/edit form with password generator (passphrase or random), strength meter, 2FA secret that accepts spaces or an otpauth:// link and shows the current code to check, copy buttons on both links, prefill from asset, contact or vendor; new Change password window that dates and logs the change; new Share window from anywhere (contact or email, 1 hour to 1 month, gone after opened once by default, link copied); same login controls on asset and contact pages and quick looks, vendor Logins tab, license page and quick look, service quick look, client overview favourites and search; credential pickers show icons and say when a credential moves from another asset or contact; client overview Passwords due for a change attention item and Active share links limited to live links; rotation report with selectable span, per client counts and oldest first; more export columns; demo data gets 2FA secrets, varied password ages and logins attached to their assets. Fixes passwords being blanked when the vault session had expired, other clients' assets, contacts and tags accepted on save, bulk star using the wrong permission, credential links to assets and contacts not checking the client, the edit or link permission, or which asset or contact an unlink was for, credentials left pointing at deleted assets and contacts, share links left open after a credential was deleted, import carrying values between rows and accepting any file type, 2FA secrets saved with spaces or lowercase giving no code, the service quick look listing credentials without credential access and repeating assets, an asset login with only a username being lost, and the API not dating new passwords. Adds functions/credential.php and js/credentials.js; removes credential_model.php and the old credential show password/OTP scripts. No DB change.
2026-10-14 23:33:29 -04:00

54 lines
1.7 KiB
PHP

<?php
/*
* ITFlow - GET/POST request handler for misc (functionality that doesn't quite fit elsewhere)
*/
// Records to show per page
if(isset($_POST['change_records_per_page'])){
$records_per_page = intval($_POST['change_records_per_page']);
mysqli_query($mysqli,"UPDATE user_settings SET user_config_records_per_page = $records_per_page WHERE user_id = $session_user_id");
redirect();
}
// Revoke sharing (sharing itself is done via ajax.php)
if (isset($_GET['deactivate_shared_item'])) {
validateCSRFToken();
$item_id = intval($_GET['deactivate_shared_item']);
// Get details of the shared link
$sql = mysqli_query($mysqli, "SELECT item_type, item_related_id, item_client_id FROM shared_items WHERE item_id = $item_id");
$row = mysqli_fetch_assoc($sql);
$item_type = escapeSql($row['item_type']);
$item_related_id = intval($row['item_related_id']);
$client_id = intval($row['item_client_id']);
enforceClientAccess();
// A credential's link is turned off by someone who may see credentials
if ($item_type === 'Credential') {
enforceUserPermission('module_credential');
}
// Deactivate item id
mysqli_query($mysqli, "DELETE FROM shared_items WHERE item_id = $item_id");
// Logging
logAudit("Sharing", "Delete", "$session_name deactivated shared $item_type link Item ID: $item_related_id. Share ID $item_id", $client_id, $item_id);
if ($item_type === 'Credential') {
// In the credential's own history too
logAudit("Credential", "Unshare", "$session_name turned off a share link", $client_id, $item_related_id);
}
$_SESSION['alert_message'] = "Share Link deactivated";
redirect();
}