Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Commit

Permalink
Navigation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Sep 21, 2022
1 parent 1ddeee5 commit 95994e9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
14 changes: 10 additions & 4 deletions interface/layout/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,23 @@ setBackground()

// Tray settings open handler
event.listen("openSettings", () => {
navigate("settings")
if (state.authenticated === true) {
navigate("settings")
}
})

// Tray navigate to codes handler
event.listen("openCodes", () => {
navigate("codes")
if (state.authenticated === true) {
navigate("codes")
}
})

// Listen for focus changes
window.appWindow.onFocusChanged((focused) => {
const path = location.pathname

if (focused.payload === true) {
if (focused.payload === true && state.authenticated === true) {
if (path === "/codes") {
document.querySelector<HTMLInputElement>(".search").focus()
}
Expand All @@ -61,7 +65,9 @@ window.appWindow.onCloseRequested((event) => {
event.preventDefault()
window.appWindow.hide()

navigate("idle")
if (state.authenticated === true) {
navigate("idle")
}
}
})

Expand Down
16 changes: 14 additions & 2 deletions interface/libraries/encryption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ export const createWebAuthnLogin = async () => {
const res = await navigator.credentials.create({
publicKey: {
rp: {
name: "Authme Windows Hello",
name: "Authme Hardware Authentication",
},

user: {
id: new Uint8Array(16),
name: "Authme",
displayName: "Authme",
displayName: "Authme User",
},

pubKeyCredParams: [
Expand All @@ -110,8 +110,14 @@ export const createWebAuthnLogin = async () => {
setSettings(settings)

console.log(res)

return "ok"
} catch (error) {
dialog.message(`Failed to register your authenticator! This feature might not be supported on your machine. \n\n${error}`, { type: "error" })

console.log(error)

return "error"
}
}

Expand All @@ -129,7 +135,13 @@ export const getWebAuthnLogin = async () => {
})

console.log(res)

return "ok"
} catch (error) {
dialog.message(`Failed to login with your authenticator. Please try again! \n\n${error}`, { type: "error" })

console.log(error)

return "error"
}
}

0 comments on commit 95994e9

Please sign in to comment.