diff --git a/ui/src/accounts/AccountEntry.vue b/ui/src/accounts/AccountEntry.vue index d9fd92b41..4c128c762 100644 --- a/ui/src/accounts/AccountEntry.vue +++ b/ui/src/accounts/AccountEntry.vue @@ -11,14 +11,14 @@ import { passkeysAvailable, useAccountsStore, usePasskey } from "./accounts"; const accounts=useAccountsStore(); const step=ref(1);const recovery=ref(false);const recoveryCode=ref(""); const organisation=ref("");const workspace=ref("Default");const publicURL=ref(window.location.origin); -const name=ref("");const email=ref("");const password=ref("");const busy=ref(false);const error=ref(""); +const name=ref("");const email=ref("");const password=ref("");const busy=ref(false);const error=ref("");const notice=ref(""); const setup=computed(()=>accounts.status?.setup_required===true); const passkey=computed(()=>passkeysAvailable(accounts.status?.public_url??"")); async function submit(){ if(setup.value&&step.value===1&&!recovery.value){step.value=2;return} - busy.value=true;error.value=""; + busy.value=true;error.value="";notice.value=""; try{ - if(recovery.value){await api.recoverAccount(email.value,recoveryCode.value,password.value);recovery.value=false;password.value="";error.value="Password changed. Sign in with your new password.";return} + if(recovery.value){await api.recoverAccount(email.value,recoveryCode.value,password.value);recovery.value=false;password.value="";notice.value="Password changed. Sign in with your new password.";return} if(setup.value)await api.setupAccount({organisation_name:organisation.value,workspace_name:workspace.value,public_url:publicURL.value.replace(/\/$/,""),display_name:name.value,email:email.value,password:password.value}); else await api.signIn(email.value,password.value); password.value=""; @@ -48,6 +48,7 @@ async function signInPasskey(){busy.value=true;error.value="";try{await usePassk

At least 15 characters.

{{error}} + {{notice}}
diff --git a/ui/src/accounts/AccountPage.vue b/ui/src/accounts/AccountPage.vue index 2277fef15..abaab3d83 100644 --- a/ui/src/accounts/AccountPage.vue +++ b/ui/src/accounts/AccountPage.vue @@ -9,15 +9,15 @@ import { Card } from "@/components/ui/card"; import { Input } from "@/components/ui/input"; import { SettingRow } from "@/components/ui/setting-row"; import { Section } from "@/components/ui/section"; -import { api } from "@/lib/api"; +import { api, classifyActionError } from "@/lib/api"; import { passkeysAvailable,useAccountsStore,usePasskey } from "./accounts"; const recovery=ref(""); const makeRecovery=()=>run(async()=>{recovery.value=(await api.recoveryCode()).code}); -const accounts=useAccountsStore();const keys=ref<{id:string;name:string}[]>([]);const error=ref("");const busy=ref(false);const keyName=ref("");const current=ref("");const next=ref(""); +const accounts=useAccountsStore();const keys=ref<{id:string;name:string}[]>([]);const error=ref("");const sessionExpired=ref(false);const busy=ref(false);const keyName=ref("");const current=ref("");const next=ref(""); const eligible=computed(()=>passkeysAvailable(accounts.status?.public_url??"")); -async function load(){try{keys.value=(await api.passkeys()).passkeys}catch(cause){error.value=String((cause as Error).message||cause)}} +async function load(){try{keys.value=(await api.passkeys()).passkeys}catch(cause){error.value=String((cause as Error).message||cause);sessionExpired.value=classifyActionError(cause).kind==="session-expired"}} onMounted(load); -async function run(action:()=>Promise){busy.value=true;error.value="";try{await action()}catch(cause){error.value=String((cause as Error).message||cause)}finally{busy.value=false}} +async function run(action:()=>Promise){busy.value=true;error.value="";try{await action()}catch(cause){error.value=String((cause as Error).message||cause);sessionExpired.value=classifyActionError(cause).kind==="session-expired"}finally{busy.value=false}} const enroll=()=>run(async()=>{await usePasskey(true,keyName.value);keyName.value="";await load()}); const remove=(id:string)=>run(async()=>{await api.deletePasskey(id);await load()}); const change=()=>run(async()=>{await api.changePassword(current.value,next.value);current.value=next.value="";window.location.assign("/")}); @@ -26,7 +26,7 @@ const change=()=>run(async()=>{await api.changePassword(current.value,next.value
{{accounts.status?.user?.display_name}} Your organisation and admin account are ready. Add a passkey below, add members, or configure OIDC. - {{error}} Sign in again + {{error}} Sign in again
{{key.name}}
diff --git a/ui/src/accounts/AuthenticationPage.vue b/ui/src/accounts/AuthenticationPage.vue index 092f7b6e3..d78fb00e4 100644 --- a/ui/src/accounts/AuthenticationPage.vue +++ b/ui/src/accounts/AuthenticationPage.vue @@ -6,18 +6,18 @@ import PageHeader from "@/base/PageHeader.vue"; import { Button } from "@/components/ui/button"; import CodeView from "@/base/CodeView.vue"; import { Input } from "@/components/ui/input"; -import { api } from "@/lib/api"; +import { api, classifyActionError } from "@/lib/api"; import { SettingRow } from "@/components/ui/setting-row"; import { Section } from "@/components/ui/section"; interface Settings {public_url:string;oidc_issuer:string;oidc_audience:string;oidc_client_id:string} -const value=ref({public_url:"",oidc_issuer:"",oidc_audience:"",oidc_client_id:""});const loaded=ref(false);const error=ref("");const busy=ref(false);const saved=ref(false); +const value=ref({public_url:"",oidc_issuer:"",oidc_audience:"",oidc_client_id:""});const loaded=ref(false);const error=ref("");const sessionExpired=ref(false);const busy=ref(false);const saved=ref(false); onMounted(async()=>{try{value.value=await api.authentication();loaded.value=true}catch(cause){error.value=String((cause as Error).message||cause)}}); const redirectURI=computed(()=>`${value.value.public_url.replace(/\/$/,"")}/oauth2/callback`); -async function save(){busy.value=true;error.value="";saved.value=false;try{await api.saveAuthentication(value.value);saved.value=true}catch(cause){error.value=String((cause as Error).message||cause)}finally{busy.value=false}} +async function save(){busy.value=true;error.value="";saved.value=false;try{await api.saveAuthentication(value.value);saved.value=true}catch(cause){error.value=String((cause as Error).message||cause);sessionExpired.value=classifyActionError(cause).kind==="session-expired"}finally{busy.value=false}}