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

View File

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

2
src-tauri/Cargo.lock generated
View File

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

View File

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

View File

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

View File

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

View File

@ -163,7 +163,7 @@ export class LumeStorage {
public async checkAccount() {
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);
}

View File

@ -1,5 +1,6 @@
import * as AlertDialog from '@radix-ui/react-alert-dialog';
import { useNavigate } from 'react-router-dom';
import { toast } from 'sonner';
import { useNDK } from '@libs/ndk/provider';
import { useStorage } from '@libs/storage/provider';
@ -11,15 +12,21 @@ export function Logout() {
const navigate = useNavigate();
const logout = async () => {
ndk.signer = null;
try {
ndk.signer = null;
// remove account
await db.accountLogout();
await db.secureRemove(db.account.pubkey);
await db.secureRemove(db.account.pubkey + '-bunker');
// remove private key
await db.secureRemove(db.account.pubkey);
await db.secureRemove(db.account.pubkey + '-bunker');
// redirect to welcome screen
navigate('/auth/welcome');
// logout
await db.accountLogout();
// redirect to welcome screen
navigate('/auth/welcome');
} catch (e) {
toast.error(e);
}
};
return (
@ -33,7 +40,7 @@ export function Logout() {
</button>
</AlertDialog.Trigger>
<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">
<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">
@ -54,13 +61,15 @@ export function Logout() {
Cancel
</button>
</AlertDialog.Cancel>
<button
type="button"
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>
<AlertDialog.Action asChild>
<button
type="button"
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>
</AlertDialog.Action>
</div>
</div>
</AlertDialog.Content>