2FAuth/public/build/assets/Register-43bdadfb.js

2 lines
3.7 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{a as T,b as C,u as I,r as F,d as k,$ as K,e as l,f as u,g as _,i as t,k as V,p as c,m as n,h as i,j as p,t as d,D,I as U}from"./app-1b332c21.js";import{F as B}from"./Form-940b5f6c.js";import{w as W}from"./webauthnService-839b1903.js";/*! 2FAuth version 5.0.0 - Copyright (c) 2023 Bubka - https://github.com/Bubka/2FAuth */const P={key:0,class:"field"},M={id:"lblDeviceRegistrationSuccess",class:"label mb-5"},j=["onSubmit"],A={key:1,class:"field is-grouped"},J={class:"control"},O={class:"control"},Y=["onSubmit"],q={class:"nav-links"},X={__name:"Register",setup(z){const b=T(),m=C(),R=I(),w=F(!1),f=F(null),s=k(new B({name:"",email:"",password:"",password_confirmation:""})),r=k(new B({name:""}));async function S(o){s.password_confirmation=s.password,s.post("/user").then(e=>{b.$patch({name:e.data.name,email:e.data.email,preferences:e.data.preferences,isAdmin:e.data.is_admin??!1}),b.applyTheme(),w.value=!0})}function N(){W.register().then(o=>{const e=JSON.parse(o.config.data);f.value=e.id}).catch(o=>{o.response.status===422?m.alert({text:o.response.data.message}):m.error(o)})}function E(o){r.patch("/webauthn/credentials/"+f.value+"/name").then(()=>{m.success({text:U("auth.webauthn.device_successfully_registered")}),R.push({name:"accounts"})})}return K(()=>{m.clear()}),(o,e)=>{const $=l("font-awesome-icon"),h=l("FormField"),g=l("FormButtons"),y=l("RouterLink"),v=l("FormWrapper"),x=l("FormPasswordField"),L=l("VueFooter");return u(),_("div",null,[t(w)?(u(),V(v,{key:0,title:"auth.authentication",punchline:"auth.webauthn.enhance_security_using_webauthn"},{default:c(()=>[t(f)?(u(),_("div",P,[i("label",M,[p(d(o.$t("auth.webauthn.device_successfully_registered"))+" ",1),n($,{icon:["fas","check"]})]),i("form",{onSubmit:D(E,["prevent"]),onKeydown:e[1]||(e[1]=a=>t(r).onKeydown(a))},[n(h,{modelValue:t(r).name,"onUpdate:modelValue":e[0]||(e[0]=a=>t(r).name=a),fieldName:"name",fieldError:t(r).errors.get("name"),inputType:"text",placeholder:"iPhone 12, TouchID, Yubikey 5C",label:"auth.forms.name_this_device"},null,8,["modelValue","fieldError"]),n(g,{isBusy:t(r).isBusy,isDisabled:t(r).isDisabled,caption:"commons.continue"},null,8,["isBusy","isDisabled"])],40,j)])):(u(),_("div",A,[i("div",J,[i("button",{type:"button",id:"btnRegisterNewDevice",onClick:e[2]||(e[2]=a=>N()),class:"button is-link"},d(o.$t("auth.webauthn.register_a_device")),1)]),i("div",O,[n(y,{id:"btnMaybeLater",to:{name:"accounts"},class:"button is-text"},{default:c(()=>[p(d(o.$t("auth.maybe_later")),1)]),_:1})])]))]),_:1})):(u(),V(v,{key:1,title:"auth.register",punchline:"auth.forms.register_punchline"},{default:c(()=>[i("form",{onSubmit:D(S,["prevent"]),onKeydown:e[6]||(e[6]=a=>t(s).onKeydown(a))},[n(h,{modelValue:t(s).name,"onUpdate:modelValue":e[3]||(e[3]=a=>t(s).name=a),fieldName:"name",fieldError:t(s).errors.get("name"),inputType:"text",label:"auth.forms.name",maxLength:255,autofocus:""},null,8,["modelValue","fieldError"]),n(h,{modelValue:t(s).email,"onUpdate:modelValue":e[4]||(e[4]=a=>t(s).email=a),fieldName:"email",fieldError:t(s).errors.get("email"),inputType:"email",label:"auth.forms.email",maxLength:255},null,8,["modelValue","fieldError"]),n(x,{modelValue:t(s).password,"onUpdate:modelValue":e[5]||(e[5]=a=>t(s).password=a),fieldName:"password",fieldError:t(s).errors.get("password"),showRules:!0,label:"auth.forms.password"},null,8,["modelValue","fieldError"]),n(g,{isBusy:t(s).isBusy,isDisabled:t(s).isDisabled,caption:"auth.register",submitId:"btnRegister"},null,8,["isBusy","isDisabled"])],40,Y),i("div",q,[i("p",null,[p(d(o.$t("auth.forms.already_register"))+" ",1),n(y,{id:"lnkSignIn",to:{name:"login"},class:"is-link"},{default:c(()=>[p(d(o.$t("auth.sign_in")),1)]),_:1})])])]),_:1})),n(L)])}}};export{X as default};