File size: 760 Bytes
b0798af
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Local operator command. Never exposed through HTTP; no default password.
require('dotenv').config({quiet:true});
const {Store}=require('../dist/core/store');
const email=process.argv[2]?.trim().toLowerCase();
if(!email){console.error('Usage: npm run admin -- existing-account@example.com');process.exit(1);}
const store=new Store();
try {
  const user=store.list('users').find(u=>u.email===email);
  if(!user)throw new Error('Register this account first, then run this command on the server.');
  store.put('users',{...user,account_type:'admin'});
  console.log('Administrator role granted to the existing account. Sign in again to refresh the interface.');
} catch(error){console.error(error.message);process.exitCode=1;}
finally{store.onModuleDestroy();}