import{d as g,h as x,r,i as k,D as u,o as f,c as _,a as e,e as p,k as n,p as m,v as I,n as v,z as S,f as C}from"../index.js";import{_ as R}from"./RoleList.vue_vue_type_script_setup_true_lang-gZbir15L.js";import"../vendor.js";const U={class:"row"},V={class:"col-sm-12"},P={class:"card"},w={class:"card-header"},M=["disabled"],A=e("span",{class:"fa fa-sync"},null,-1),E=e("h3",null,"Authentication",-1),T={class:"card-body"},$={class:"col-md-6 offset-md-6"},D=e("i",{class:"fa-3x fas fa-circle-notch fa-spin"},null,-1),N=[D],B={class:"form-group"},q={class:"form-check"},z=e("label",{class:"form-check-label",for:"enableIdentityProvider"}," Enable sign-in using EzeScan Identity Management ",-1),F={class:"form-group"},L=e("label",{for:"identityProviderAuthority",class:"control-label"},"Authority",-1),j=e("p",{class:"help-text small"},"The authority address of EIM service.",-1),G={class:"form-group"},H=e("label",{for:"identityProviderClientId",class:"control-label"},"Client Id",-1),J=e("p",{class:"help-text small"},"The client id from the app registration in EIM.",-1),K={class:"form-group"},O=e("label",{for:"identityProviderClientSecret",class:"control-label"},"Client Secret",-1),Q=e("p",{class:"help-text small"},"The client secret from the app registration in EIM. Leave blank to keep the current secret.",-1),W=e("br",null,null,-1),X={class:"form-group"},Y=e("label",{for:"defaultUserRolesInput",class:"control-label"},"Default User Roles",-1),Z=e("p",{class:"help-text small"},"Default roles to assign to new users the first time they sign-in.",-1),ee={key:0,class:"text-danger"},te={class:"float-right"},se=e("i",{class:"fa fa-save"},null,-1),ie=g({__name:"Authentication",setup(oe){const h=x(),i=r(!1),s=r({}),l=r([]),d=r(!0);k(async()=>{await c()});async function c(){i.value=!0,s.value={enabled:!1,authority:"",clientId:"",clientSecret:"",defaultUserRoles:[]};try{s.value=await h.settings.identityProvider.get(),l.value=s.value.defaultUserRoles??[],i.value=!1}catch(a){u({type:"error",text:`Fetch authentication settings failed. Reason: ${a}`})}}async function y(){try{if(!b())return;const a={...s.value,defaultUserRoles:l.value};await h.settings.identityProvider.put(a),u({type:"success",text:"Authentication settings saved."}),await c()}catch(a){u({type:"error",text:`Save authentication settings failed. Reason: ${a.errorMessage}`})}}function b(){return d.value=l.value&&l.value.length>0,d.value}return(a,t)=>(f(),_("div",U,[e("div",V,[e("div",P,[e("div",w,[e("button",{class:"btn btn-sm btn-outline-primary rounded-pill float-right",disabled:i.value,onClick:t[0]||(t[0]=o=>c())},[A,p(" Refresh ")],8,M),E]),e("div",T,[n(e("div",$,N,512),[[m,i.value]]),n(e("div",null,[e("div",B,[e("div",q,[n(e("input",{class:"form-check-input",type:"checkbox",id:"enableIdentityProvider","onUpdate:modelValue":t[1]||(t[1]=o=>s.value.enabled=o)},null,512),[[I,s.value.enabled]]),z])]),e("div",F,[L,n(e("input",{class:"form-control",id:"identityProviderAuthority","onUpdate:modelValue":t[2]||(t[2]=o=>s.value.authority=o)},null,512),[[v,s.value.authority]]),j]),e("div",G,[H,n(e("input",{class:"form-control",id:"identityProviderClientId","onUpdate:modelValue":t[3]||(t[3]=o=>s.value.clientId=o)},null,512),[[v,s.value.clientId]]),J]),e("div",K,[O,n(e("input",{class:"form-control",id:"identityProviderClientSecret","onUpdate:modelValue":t[4]||(t[4]=o=>s.value.clientSecret=o)},null,512),[[v,s.value.clientSecret]]),Q]),W,e("div",X,[Y,Z,S(R,{modelValue:l.value,"onUpdate:modelValue":t[5]||(t[5]=o=>l.value=o)},null,8,["modelValue"]),d.value?C("",!0):(f(),_("div",ee,"At least one role is required."))]),e("div",te,[e("button",{type:"button",onClick:t[6]||(t[6]=o=>y()),class:"btn btn-success"},[se,p(" Save ")])])],512),[[m,!i.value]])])])])]))}});export{ie as default};
