Merge pull request #120 from luminous-devs/fix/logout

Fix logout function and other issues
This commit is contained in:
Ren Amamiya 2023-11-23 08:54:24 +07:00 committed by GitHub
commit 2fdf437789
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 54 additions and 47 deletions

View File

@ -2,7 +2,7 @@
"name": "lume", "name": "lume",
"description": "the communication app", "description": "the communication app",
"private": true, "private": true,
"version": "2.1.2", "version": "2.1.3",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "vite build", "build": "vite build",
@ -63,7 +63,7 @@
"html-to-text": "^9.0.5", "html-to-text": "^9.0.5",
"idb-keyval": "^6.2.1", "idb-keyval": "^6.2.1",
"light-bolt11-decoder": "^3.0.0", "light-bolt11-decoder": "^3.0.0",
"lru-cache": "^10.0.3", "lru-cache": "^10.1.0",
"markdown-to-jsx": "^7.3.2", "markdown-to-jsx": "^7.3.2",
"media-chrome": "^1.5.3", "media-chrome": "^1.5.3",
"minidenticons": "^4.2.0", "minidenticons": "^4.2.0",
@ -77,7 +77,7 @@
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-hook-form": "^7.48.2", "react-hook-form": "^7.48.2",
"react-hotkeys-hook": "^4.4.1", "react-hotkeys-hook": "^4.4.1",
"react-router-dom": "^6.19.0", "react-router-dom": "^6.20.0",
"react-string-replace": "^1.1.1", "react-string-replace": "^1.1.1",
"reactflow": "^11.10.1", "reactflow": "^11.10.1",
"sonner": "^1.2.2", "sonner": "^1.2.2",
@ -85,7 +85,7 @@
"tauri-controls": "github:reyamir/tauri-controls", "tauri-controls": "github:reyamir/tauri-controls",
"tippy.js": "^6.3.7", "tippy.js": "^6.3.7",
"tiptap-markdown": "^0.8.4", "tiptap-markdown": "^0.8.4",
"virtua": "^0.16.5", "virtua": "^0.16.6",
"zustand": "^4.4.6" "zustand": "^4.4.6"
}, },
"devDependencies": { "devDependencies": {

View File

@ -141,8 +141,8 @@ dependencies:
specifier: ^3.0.0 specifier: ^3.0.0
version: 3.0.0 version: 3.0.0
lru-cache: lru-cache:
specifier: ^10.0.3 specifier: ^10.1.0
version: 10.0.3 version: 10.1.0
markdown-to-jsx: markdown-to-jsx:
specifier: ^7.3.2 specifier: ^7.3.2
version: 7.3.2(react@18.2.0) version: 7.3.2(react@18.2.0)
@ -183,8 +183,8 @@ dependencies:
specifier: ^4.4.1 specifier: ^4.4.1
version: 4.4.1(react-dom@18.2.0)(react@18.2.0) version: 4.4.1(react-dom@18.2.0)(react@18.2.0)
react-router-dom: react-router-dom:
specifier: ^6.19.0 specifier: ^6.20.0
version: 6.19.0(react-dom@18.2.0)(react@18.2.0) version: 6.20.0(react-dom@18.2.0)(react@18.2.0)
react-string-replace: react-string-replace:
specifier: ^1.1.1 specifier: ^1.1.1
version: 1.1.1 version: 1.1.1
@ -207,8 +207,8 @@ dependencies:
specifier: ^0.8.4 specifier: ^0.8.4
version: 0.8.4(@tiptap/core@2.1.12) version: 0.8.4(@tiptap/core@2.1.12)
virtua: virtua:
specifier: ^0.16.5 specifier: ^0.16.6
version: 0.16.5(react-dom@18.2.0)(react@18.2.0) version: 0.16.6(react-dom@18.2.0)(react@18.2.0)
zustand: zustand:
specifier: ^4.4.6 specifier: ^4.4.6
version: 4.4.6(@types/react@18.2.38)(react@18.2.0) version: 4.4.6(@types/react@18.2.38)(react@18.2.0)
@ -1845,8 +1845,8 @@ packages:
type-fest: 2.19.0 type-fest: 2.19.0
dev: false dev: false
/@remix-run/router@1.12.0: /@remix-run/router@1.13.0:
resolution: {integrity: sha512-2hXv036Bux90e1GXTWSMfNzfDDK8LA8JYEWfyHxzvwdp6GyoWEovKc9cotb3KCKmkdwsIBuFGX7ScTWyiHv7Eg==} resolution: {integrity: sha512-5dMOnVnefRsl4uRnAdoWjtVTdh8e6aZqgM4puy9nmEADH72ck+uXwzpJLEKE9Q6F8ZljNewLgmTfkxUrBdv4WA==}
engines: {node: '>=14.0.0'} engines: {node: '>=14.0.0'}
dev: false dev: false
@ -3146,7 +3146,7 @@ packages:
hasBin: true hasBin: true
dependencies: dependencies:
caniuse-lite: 1.0.30001564 caniuse-lite: 1.0.30001564
electron-to-chromium: 1.4.590 electron-to-chromium: 1.4.592
node-releases: 2.0.13 node-releases: 2.0.13
update-browserslist-db: 1.0.13(browserslist@4.22.1) update-browserslist-db: 1.0.13(browserslist@4.22.1)
dev: true dev: true
@ -3519,8 +3519,8 @@ packages:
resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==}
dev: true dev: true
/electron-to-chromium@1.4.590: /electron-to-chromium@1.4.592:
resolution: {integrity: sha512-hohItzsQcG7/FBsviCYMtQwUSWvVF7NVqPOnJCErWsAshsP/CR2LAXdmq276RbESNdhxiAq5/vRo1g2pxGXVww==} resolution: {integrity: sha512-D3NOkROIlF+d5ixnz7pAf3Lu/AuWpd6AYgI9O67GQXMXTcCP1gJQRotOq35eQy5Sb4hez33XH1YdTtILA7Udww==}
dev: true dev: true
/emoji-regex@9.2.2: /emoji-regex@9.2.2:
@ -4627,8 +4627,8 @@ packages:
dependencies: dependencies:
js-tokens: 4.0.0 js-tokens: 4.0.0
/lru-cache@10.0.3: /lru-cache@10.1.0:
resolution: {integrity: sha512-B7gr+F6MkqB3uzINHXNctGieGsRTMwIBgxkp0yq/5BwcuDzD4A8wQpHQW6vDAm1uKSLQghmRdD9sKqf2vJ1cEg==} resolution: {integrity: sha512-/1clY/ui8CzjKFyjdvwPWJUYKiFVXG2I2cY0ssG7h4+hwk+XOIX7ZSG9Q7TW8TW3Kp3BUSqgFWBLgL4PJ+Blag==}
engines: {node: 14 || >=16.14} engines: {node: 14 || >=16.14}
dev: false dev: false
@ -5396,26 +5396,26 @@ packages:
use-sidecar: 1.1.2(@types/react@18.2.38)(react@18.2.0) use-sidecar: 1.1.2(@types/react@18.2.38)(react@18.2.0)
dev: false dev: false
/react-router-dom@6.19.0(react-dom@18.2.0)(react@18.2.0): /react-router-dom@6.20.0(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-N6dWlcgL2w0U5HZUUqU2wlmOrSb3ighJmtQ438SWbhB1yuLTXQ8yyTBMK3BSvVjp7gBtKurT554nCtMOgxCZmQ==} resolution: {integrity: sha512-CbcKjEyiSVpA6UtCHOIYLUYn/UJfwzp55va4yEfpk7JBN3GPqWfHrdLkAvNCcpXr8QoihcDMuk0dzWZxtlB/mQ==}
engines: {node: '>=14.0.0'} engines: {node: '>=14.0.0'}
peerDependencies: peerDependencies:
react: '>=16.8' react: '>=16.8'
react-dom: '>=16.8' react-dom: '>=16.8'
dependencies: dependencies:
'@remix-run/router': 1.12.0 '@remix-run/router': 1.13.0
react: 18.2.0 react: 18.2.0
react-dom: 18.2.0(react@18.2.0) react-dom: 18.2.0(react@18.2.0)
react-router: 6.19.0(react@18.2.0) react-router: 6.20.0(react@18.2.0)
dev: false dev: false
/react-router@6.19.0(react@18.2.0): /react-router@6.20.0(react@18.2.0):
resolution: {integrity: sha512-0W63PKCZ7+OuQd7Tm+RbkI8kCLmn4GPjDbX61tWljPxWgqTKlEpeQUwPkT1DRjYhF8KSihK0hQpmhU4uxVMcdw==} resolution: {integrity: sha512-pVvzsSsgUxxtuNfTHC4IxjATs10UaAtvLGVSA1tbUE4GDaOSU1Esu2xF5nWLz7KPiMuW8BJWuPFdlGYJ7/rW0w==}
engines: {node: '>=14.0.0'} engines: {node: '>=14.0.0'}
peerDependencies: peerDependencies:
react: '>=16.8' react: '>=16.8'
dependencies: dependencies:
'@remix-run/router': 1.12.0 '@remix-run/router': 1.13.0
react: 18.2.0 react: 18.2.0
dev: false dev: false
@ -6095,8 +6095,8 @@ packages:
/util-deprecate@1.0.2: /util-deprecate@1.0.2:
resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
/virtua@0.16.5(react-dom@18.2.0)(react@18.2.0): /virtua@0.16.6(react-dom@18.2.0)(react@18.2.0):
resolution: {integrity: sha512-ClnVq9N8z05TGZS3p0ABcyioyhFugDNhC37BXsM8HfFDQ1bCiu9SdJh2YuVJioGPzpYs6PtjwHZU9hWQvWU3gQ==} resolution: {integrity: sha512-I2vFlh7sCUTK4nVZzPj2IhgGRFtNVrVQD2nrpFPedotjcLjeE3Z9cJslGsU4Go2y65kBymwqT19Hwkycs4IFVQ==}
peerDependencies: peerDependencies:
react: '>=16.14.0' react: '>=16.14.0'
react-dom: '>=16.14.0' react-dom: '>=16.14.0'

2
src-tauri/Cargo.lock generated
View File

@ -2660,7 +2660,7 @@ dependencies = [
[[package]] [[package]]
name = "lume" name = "lume"
version = "2.1.2" version = "2.1.3"
dependencies = [ dependencies = [
"keyring", "keyring",
"serde", "serde",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "lume" name = "lume"
version = "2.1.2" version = "2.1.3"
description = "the communication app" description = "the communication app"
authors = ["Ren Amamiya"] authors = ["Ren Amamiya"]
license = "GPL-3.0" license = "GPL-3.0"

View File

@ -9,7 +9,7 @@
}, },
"package": { "package": {
"productName": "Lume", "productName": "Lume",
"version": "2.1.2" "version": "2.1.3"
}, },
"plugins": { "plugins": {
"fs": { "fs": {

View File

@ -45,8 +45,6 @@ export function CreateAccountScreen() {
const onSubmit = async (data: { name: string; about: string }) => { const onSubmit = async (data: { name: string; about: string }) => {
try { try {
if (!ndk.signer) return navigate('/new/privkey');
setLoading(true); setLoading(true);
const profile = { const profile = {

View File

@ -163,7 +163,7 @@ export class LumeStorage {
public async checkAccount() { public async checkAccount() {
const result: Array<{ total: string }> = await this.db.select( const result: Array<{ total: string }> = await this.db.select(
'SELECT COUNT(*) AS "total" FROM accounts;' 'SELECT COUNT(*) AS "total" FROM accounts WHERE is_active = "1" ORDER BY id DESC LIMIT 1;'
); );
return parseInt(result[0].total); return parseInt(result[0].total);
} }

View File

@ -1,5 +1,6 @@
import * as AlertDialog from '@radix-ui/react-alert-dialog'; import * as AlertDialog from '@radix-ui/react-alert-dialog';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import { toast } from 'sonner';
import { useNDK } from '@libs/ndk/provider'; import { useNDK } from '@libs/ndk/provider';
import { useStorage } from '@libs/storage/provider'; import { useStorage } from '@libs/storage/provider';
@ -11,15 +12,21 @@ export function Logout() {
const navigate = useNavigate(); const navigate = useNavigate();
const logout = async () => { const logout = async () => {
ndk.signer = null; try {
ndk.signer = null;
// remove account // remove private key
await db.accountLogout(); await db.secureRemove(db.account.pubkey);
await db.secureRemove(db.account.pubkey); await db.secureRemove(db.account.pubkey + '-bunker');
await db.secureRemove(db.account.pubkey + '-bunker');
// redirect to welcome screen // logout
navigate('/auth/welcome'); await db.accountLogout();
// redirect to welcome screen
navigate('/auth/welcome');
} catch (e) {
toast.error(e);
}
}; };
return ( return (
@ -33,7 +40,7 @@ export function Logout() {
</button> </button>
</AlertDialog.Trigger> </AlertDialog.Trigger>
<AlertDialog.Portal> <AlertDialog.Portal>
<AlertDialog.Overlay className="fixed inset-0 z-50 bg-black/50 backdrop-blur-2xl dark:bg-white/50" /> <AlertDialog.Overlay className="fixed inset-0 z-50 bg-black/20 backdrop-blur-sm dark:bg-black/20" />
<AlertDialog.Content className="fixed inset-0 z-50 flex min-h-full items-center justify-center"> <AlertDialog.Content className="fixed inset-0 z-50 flex min-h-full items-center justify-center">
<div className="relative h-min w-full max-w-md rounded-xl bg-neutral-100 dark:bg-neutral-900"> <div className="relative h-min w-full max-w-md rounded-xl bg-neutral-100 dark:bg-neutral-900">
<div className="flex flex-col gap-1 border-b border-white/5 px-5 py-4"> <div className="flex flex-col gap-1 border-b border-white/5 px-5 py-4">
@ -54,13 +61,15 @@ export function Logout() {
Cancel Cancel
</button> </button>
</AlertDialog.Cancel> </AlertDialog.Cancel>
<button <AlertDialog.Action asChild>
type="button" <button
onClick={() => logout()} type="button"
className="inline-flex h-9 items-center justify-center rounded-lg bg-red-500 px-4 text-sm font-medium text-white outline-none hover:bg-red-600" onClick={() => logout()}
> className="inline-flex h-9 items-center justify-center rounded-lg bg-red-500 px-4 text-sm font-medium text-white outline-none hover:bg-red-600"
Logout >
</button> Logout
</button>
</AlertDialog.Action>
</div> </div>
</div> </div>
</AlertDialog.Content> </AlertDialog.Content>