forked from unimatrix/web
Add restricted treasury transfers and service account overview
This commit is contained in:
parent
bc4f0a00df
commit
c4a17f0d54
1 changed files with 50 additions and 7 deletions
|
|
@ -46,12 +46,12 @@ export function createPostbankApi(central,bank,settings={},deps={}){
|
|||
}
|
||||
if(path.startsWith('/api/bank/admin/')){
|
||||
try{
|
||||
if(path==='/api/bank/admin/transfers/cancel'){
|
||||
if(['/api/bank/admin/transfers/cancel','/api/bank/admin/treasuries/transfer'].includes(path)){
|
||||
if(request.method!=='POST')return reply({message:'Method not allowed.'},405);
|
||||
if(request.headers.get('origin')!==origin)return reply({message:'Request origin rejected.'},403);
|
||||
if(!/^application\/json(?:;|$)/i.test(request.headers.get('content-type')||''))return reply({message:'JSON required.'},415);
|
||||
if(url.search)return reply({message:'Account overrides are not accepted.'},400);const raw=await request.text();if(raw.length>2000)return reply({message:'Request too large.'},413);let input;try{input=JSON.parse(raw);}catch{return reply({message:'Complete the cancellation form.'},400);}
|
||||
return reply(await admin.cancel(user,input,{revalidate:()=>auth(request)}));
|
||||
return reply(await (path.endsWith('/cancel')?admin.cancel(user,input,{revalidate:()=>auth(request)}):admin.treasuryTransfer(user,input,{revalidate:()=>auth(request)})));
|
||||
}
|
||||
if(request.method!=='GET')return reply({message:'Method not allowed.'},405);
|
||||
const permitted=path.endsWith('/overview')?[]:path.endsWith('/accounts')?['entityId']:path.endsWith('/activity')?['accountId','page']:['q','kind','page'];if([...url.searchParams.keys()].some(k=>!permitted.includes(k)||url.searchParams.getAll(k).length!==1))return reply({message:'Invalid bank administration filter.'},400);
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff