fix: add /api/organizations + personal /api/usage fallbacks in login JS
This commit is contained in:
@@ -71,12 +71,21 @@ public partial class LoginWindow : Window
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
const string script = @"(async()=>{try{
|
const string script = @"(async()=>{try{
|
||||||
const b=await(await fetch('/api/bootstrap',{headers:{accept:'application/json'}})).json();
|
const h={headers:{accept:'application/json'}};
|
||||||
const id=b?.memberships?.[0]?.organization?.uuid||b?.organizations?.[0]?.uuid
|
const b=await(await fetch('/api/bootstrap',h)).json();
|
||||||
||b?.default_organization?.uuid||null;
|
let id=b?.memberships?.[0]?.organization?.uuid||b?.organizations?.[0]?.uuid
|
||||||
|
||b?.default_organization?.uuid||null;
|
||||||
const e=b?.account?.email_address||b?.account?.email||b?.email||null;
|
const e=b?.account?.email_address||b?.account?.email||b?.email||null;
|
||||||
if(!id)return{email:e,orgId:null,usage:null};
|
if(!id){
|
||||||
const u=await(await fetch('/api/organizations/'+id+'/usage',{headers:{accept:'application/json'}})).json();
|
try{const ol=await(await fetch('/api/organizations',h)).json();
|
||||||
|
if(Array.isArray(ol)&&ol.length>0)id=ol[0]?.uuid||null;}catch(e2){}
|
||||||
|
}
|
||||||
|
if(!id){
|
||||||
|
try{const pu=await(await fetch('/api/usage',h)).json();
|
||||||
|
if(pu&&!pu.error)return{email:e,orgId:null,usage:pu};}catch(e3){}
|
||||||
|
return{email:e,orgId:null,usage:null};
|
||||||
|
}
|
||||||
|
const u=await(await fetch('/api/organizations/'+id+'/usage',h)).json();
|
||||||
return{email:e,orgId:id,usage:u};
|
return{email:e,orgId:id,usage:u};
|
||||||
}catch(ex){return{error:String(ex)};}})()";
|
}catch(ex){return{error:String(ex)};}})()";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user