mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2025-10-03 15:56:17 +00:00
2 lines
3.2 KiB
JavaScript
2 lines
3.2 KiB
JavaScript
import{_ as h,c as m,a as t,b as i,h as d,t as p,m as f,y as _,j as r,w as c,z as b,D as v,g,f as n}from"./index-CH_t_ZbZ.js";import{Q as x}from"./browser-CnAb55uL.js";import{L as y}from"./localeText-2Ol_NUBB.js";const T={name:"totp",components:{LocaleText:y},async setup(){const s=v();let e="";return await g("/api/Welcome_GetTotpLink",{},a=>{a.status&&(e=a.data)}),{l:e,store:s}},mounted(){this.l&&x.toCanvas(document.getElementById("qrcode"),this.l,function(s){})},data(){return{totp:"",totpInvalidMessage:"",verified:!1}},methods:{validateTotp(){}},watch:{totp(s){const e=document.querySelector("#totp");e.classList.remove("is-invalid","is-valid"),s.length===6&&(console.log(s),/[0-9]{6}/.test(s)?b("/api/Welcome_VerifyTotpLink",{totp:s},a=>{a.status?(this.verified=!0,e.classList.add("is-valid"),this.$emit("verified")):(e.classList.add("is-invalid"),this.totpInvalidMessage="TOTP does not match.")}):(e.classList.add("is-invalid"),this.totpInvalidMessage="TOTP can only contain numbers"))}}},k=["data-bs-theme"],L={class:"m-auto text-body",style:{width:"500px"}},w={class:"d-flex flex-column"},C={class:"dashboardLogo display-4"},M={class:"mb-2"},P={class:"text-muted"},I={class:"p-3 bg-body-secondary rounded-3 border mb-3"},O={class:"text-muted mb-0"},B=["href"],$={style:{"line-break":"anywhere"}},D={for:"totp",class:"mb-2"},R={class:"text-muted"},S={class:"form-group mb-2"},q=["disabled"],A={class:"invalid-feedback"},E={class:"valid-feedback"},F={class:"d-flex gap-3 mt-5 flex-column"};function Q(s,e,a,G,N,W){const o=d("LocaleText"),l=d("RouterLink");return n(),m("div",{class:"container-fluid login-container-fluid d-flex main pt-5 overflow-scroll","data-bs-theme":this.store.Configuration.Server.dashboard_theme},[t("div",L,[t("div",w,[t("div",null,[t("h1",C,[i(o,{t:"Multi-Factor Authentication (MFA)"})]),t("p",M,[t("small",P,[i(o,{t:"1. Please scan the following QR Code to generate TOTP with your choice of authenticator"})])]),e[1]||(e[1]=t("canvas",{id:"qrcode",class:"rounded-3 mb-2"},null,-1)),t("div",I,[t("p",O,[t("small",null,[i(o,{t:"Or you can click the link below:"})])]),t("a",{href:this.l},[t("code",$,p(this.l),1)],8,B)]),t("label",D,[t("small",R,[i(o,{t:"2. Enter the TOTP generated by your authenticator to verify"})])]),t("div",S,[f(t("input",{class:"form-control text-center totp",id:"totp",maxlength:"6",type:"text",inputmode:"numeric",autocomplete:"one-time-code","onUpdate:modelValue":e[0]||(e[0]=u=>this.totp=u),disabled:this.verified},null,8,q),[[_,this.totp]]),t("div",A,[i(o,{t:this.totpInvalidMessage},null,8,["t"])]),t("div",E,[i(o,{t:"TOTP verified!"})])])]),e[4]||(e[4]=t("hr",null,null,-1)),t("div",F,[this.verified?(n(),r(l,{key:1,to:"/",class:"btn btn-dark btn-lg d-flex btn-brand shadow align-items-center flex-grow-1 rounded-3"},{default:c(()=>[i(o,{t:"Complete"}),e[3]||(e[3]=t("i",{class:"bi bi-chevron-right ms-auto"},null,-1))]),_:1,__:[3]})):(n(),r(l,{key:0,to:"/",class:"btn bg-secondary-subtle text-secondary-emphasis rounded-3 flex-grow-1 btn-lg border-1 border-secondary-subtle shadow d-flex"},{default:c(()=>[i(o,{t:"I don't need MFA"}),e[2]||(e[2]=t("i",{class:"bi bi-chevron-right ms-auto"},null,-1))]),_:1,__:[2]}))])])])],8,k)}const V=h(T,[["render",Q]]);export{V as default};
|