From 14bb0ff6e6609ddaad71a276a1093682c6c2c0b0 Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Fri, 7 Jul 2023 10:53:48 +0300 Subject: [PATCH] fix: login --- static/js/market.js | 18 +++++++++------- templates/nostrmarket/market.html | 36 +++++++++---------------------- 2 files changed, 20 insertions(+), 34 deletions(-) diff --git a/static/js/market.js b/static/js/market.js index 681ab28..0ce9162 100644 --- a/static/js/market.js +++ b/static/js/market.js @@ -135,7 +135,7 @@ const market = async () => { this.shoppingCarts = this.$q.localStorage.getItem('nostrmarket.shoppingCarts') || [] // Check for user stored - this.account = this.$q.localStorage.getItem('diagonAlley.account') || null + this.account = this.$q.localStorage.getItem('nostrmarket.account') || null //console.log("UUID", crypto.randomUUID()) // Check for stored merchants and relays on localStorage @@ -209,23 +209,24 @@ const market = async () => { `This will delete all stored data. If you didn't backup the Key Pair (Private and Public Keys), you will lose it. Continue?` ) .onOk(() => { - window.localStorage.removeItem('diagonAlley.account') + window.localStorage.removeItem('nostrmarket.account') this.account = null }) }, async createAccount(useExtension = false) { + console.log('### createAccount',) let nip07 if (useExtension) { await this.getFromExtension() nip07 = true } - if (this.isValidKey) { + if (isValidKey(this.accountDialog.data.key, 'nsec')) { let { key, watchOnly } = this.accountDialog.data if (key.startsWith('n')) { let { type, data } = NostrTools.nip19.decode(key) key = data } - this.$q.localStorage.set('diagonAlley.account', { + this.$q.localStorage.set('nostrmarket.account', { privkey: watchOnly ? null : key, pubkey: watchOnly ? key : NostrTools.getPublicKey(key), useExtension: nip07 ?? false @@ -235,8 +236,9 @@ const market = async () => { key: null } this.accountDialog.show = false - this.account = this.$q.localStorage.getItem('diagonAlley.account') + this.account = this.$q.localStorage.getItem('nostrmarket.account') } + this.accountDialog.show = false }, generateKeyPair() { this.accountDialog.data.key = NostrTools.generatePrivateKey() @@ -585,7 +587,7 @@ const market = async () => { if (!product) { product = { ...item, orderedQuantity: 1 } stallCart.products.push(product) - + } product.orderedQuantity = Math.min(product.quantity, item.orderedQuantity || (product.orderedQuantity + 1)) @@ -597,8 +599,8 @@ const market = async () => { const stallCart = this.shoppingCarts.find(c => c.id === item.stallId) if (stallCart) { stallCart.products = stallCart.products.filter(p => p.id !== item.productId) - if (!stallCart.products.length){ - this.shoppingCarts = this.shoppingCarts.filter(s => s.id !== item.stallId) + if (!stallCart.products.length) { + this.shoppingCarts = this.shoppingCarts.filter(s => s.id !== item.stallId) } this.$q.localStorage.set('nostrmarket.shoppingCarts', this.shoppingCarts) } diff --git a/templates/nostrmarket/market.html b/templates/nostrmarket/market.html index d3b8d33..aa109e7 100644 --- a/templates/nostrmarket/market.html +++ b/templates/nostrmarket/market.html @@ -224,44 +224,28 @@ - - - + + +
Account Setup
-
-

Type your Nostr private key or generate a new one.

- You can also use a Nostr-capable extension. +

Enter your Nostr private key or generate a new one.

- - - - - - - - Is this a Public Key? - - If not using an Nostr capable extension, you'll have to sign - events manually! Better to use a Private Key that you can delete - later, or just generate an ephemeral key pair to use in the - Marketplace! - - - + hint="Enter you private key"> - - + + Close