feat(khira): require admin password confirmation for database backup and rollback
This commit is contained in:
+12
-6
@@ -302,10 +302,13 @@ function adminSyncDB(){
|
||||
dlg({
|
||||
title:'Sync Primary DB to Backup DB',
|
||||
sub:'Mirror all primary database tables to the backup database.',
|
||||
body:'<p>This will overwrite the backup database with the current primary database state (users, tickets, remarks, attachments, errors). Proceed with synchronization?</p>',
|
||||
body:`<p style="margin-bottom:12px">This will overwrite the backup database with the current primary database state (users, tickets, remarks, attachments, errors).</p>
|
||||
<p style="font-size:13px;color:var(--on-sv);margin-bottom:8px">Please enter your administrator password to proceed:</p>
|
||||
${fld('password','Admin Password',{t:'password',req:1})}`,
|
||||
ok:'Sync Backup DB',
|
||||
go:async()=>{
|
||||
const r=await api('/khira/api/admin/db/sync','POST');
|
||||
go:async(v)=>{
|
||||
if(!v.password){toast('Admin password is required','err');return false}
|
||||
const r=await api('/khira/api/admin/db/sync','POST',{password:v.password});
|
||||
if(r._f||r.error){toast(r.error||'Database sync failed','err');return false}
|
||||
toast(r.message||'Backup database synced successfully');
|
||||
await refresh();
|
||||
@@ -317,10 +320,13 @@ function adminRollbackDB(){
|
||||
dlg({
|
||||
title:'Rollback Primary DB from Backup',
|
||||
sub:'Restore primary database state from the backup database.',
|
||||
body:'<p style="color:var(--err);font-weight:500"><span class="ms">warning</span> WARNING: This will overwrite current primary database records with the latest backup state. Any data created since the last backup sync will be replaced.</p><p style="margin-top:8px">Are you sure you want to rollback?</p>',
|
||||
body:`<p style="color:var(--err);font-weight:500;margin-bottom:8px"><span class="ms">warning</span> WARNING: This will overwrite current primary database records with the latest backup state. Any data created since the last backup sync will be replaced.</p>
|
||||
<p style="font-size:13px;color:var(--on-sv);margin-bottom:8px">Please enter your administrator password to confirm rollback:</p>
|
||||
${fld('password','Admin Password',{t:'password',req:1})}`,
|
||||
ok:'Rollback to Backup',
|
||||
go:async()=>{
|
||||
const r=await api('/khira/api/admin/db/rollback','POST');
|
||||
go:async(v)=>{
|
||||
if(!v.password){toast('Admin password is required','err');return false}
|
||||
const r=await api('/khira/api/admin/db/rollback','POST',{password:v.password});
|
||||
if(r._f||r.error){toast(r.error||'Rollback failed','err');return false}
|
||||
toast(r.message||'Primary database rolled back successfully');
|
||||
await refresh();
|
||||
|
||||
Reference in New Issue
Block a user