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

Commit

Permalink
Import and encryption fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Sep 17, 2022
1 parent fd8a4d8 commit 9a4ed32
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 103 deletions.
15 changes: 10 additions & 5 deletions core/src/encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,21 @@ pub fn decrypt_data(data: String) -> String {
}

#[tauri::command]
pub fn set_entry(name: String, data: String) {
let service = "authme_dev";
pub fn set_entry(name: String, data: String) -> String {
let service = "authme";
let entry = keyring::Entry::new(&service, &name);

entry.set_password(data.as_str()).unwrap();
let res = entry.set_password(data.as_str());

match res {
Ok(_) => "ok".into(),
Err(_) => "error".into(),
}
}

#[tauri::command]
pub fn get_entry(name: String) -> String {
let service = "authme_dev";
let service = "authme";
let entry = keyring::Entry::new(&service, &name);

let item = entry.get_password().unwrap_or_else(|error| "error".into());
Expand All @@ -78,7 +83,7 @@ pub fn get_entry(name: String) -> String {

#[tauri::command]
pub fn delete_entry(name: String) {
let service = "authme_dev";
let service = "authme";
let entry = keyring::Entry::new(&service, &name);

let item = entry.delete_password();
Expand Down
8 changes: 7 additions & 1 deletion interface/libraries/encryption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ export const decryptData = async (data: string): Promise<string> => {
* Sets an entry on the system keychain
*/
export const setEntry = async (name: string, data: string) => {
await invoke("set_entry", { name, data })
const res = await invoke("set_entry", { name, data })

if (res === "error") {
dialog.message("Failed to set the encryption key on your systems keychain!\n\n You can use the password method.", { type: "error" })
}

return res
}

/**
Expand Down
2 changes: 1 addition & 1 deletion interface/windows/import/import.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
</div>

<dialog class="dialog dialog1 overflow-hidden">
<h2>Capture screen</h2>
<h2 class="dialog1Title">Capture screen import</h2>
<h3>Waiting for a QR code...</h3>

<div class="mt-10 flex aspect-video h-60 flex-row space-x-5">
Expand Down
4 changes: 4 additions & 0 deletions interface/windows/import/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ export const captureScreen = async () => {
const dialogElement: LibDialogElement = document.querySelector(".dialog1")
const videoElement: HTMLVideoElement = document.querySelector(".video")

document.querySelector(".dialog1Title").textContent = "Capture screen import"

try {
videoElement.srcObject = await navigator.mediaDevices.getDisplayMedia({ audio: false })

Expand Down Expand Up @@ -214,6 +216,8 @@ const webcamAvailable = async () => {
export const useWebcam = async () => {
const hasWebcam = await webcamAvailable()

document.querySelector(".dialog1Title").textContent = "Webcam import"

if (hasWebcam === false) {
// Not found webcam
dialog.message("Not found webcam! \n\nPlease check if your webcam is working correctly or not used by another application.", { type: "error" })
Expand Down
Loading

0 comments on commit 9a4ed32

Please sign in to comment.