From 6dd34dd253641879e4fb49c4ffcf93c707aca9d0 Mon Sep 17 00:00:00 2001 From: MTG2000 Date: Sun, 21 Aug 2022 14:32:09 +0300 Subject: [PATCH 1/7] update: add warn msg to adding new account --- .../LinkedAccountsCard/LinkedAccountsCard.tsx | 1 + src/mocks/data/users.ts | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/features/Profiles/pages/EditProfilePage/PreferencesTab/LinkedAccountsCard/LinkedAccountsCard.tsx b/src/features/Profiles/pages/EditProfilePage/PreferencesTab/LinkedAccountsCard/LinkedAccountsCard.tsx index 6f38f33..207a4f6 100644 --- a/src/features/Profiles/pages/EditProfilePage/PreferencesTab/LinkedAccountsCard/LinkedAccountsCard.tsx +++ b/src/features/Profiles/pages/EditProfilePage/PreferencesTab/LinkedAccountsCard/LinkedAccountsCard.tsx @@ -81,6 +81,7 @@ export default function LinkedAccountsCard({ value, onChange }: Props) { } +

Note: if you link a wallet that was used to create another account previously, you won't be able to login to that account until you remove it from here.

) } diff --git a/src/mocks/data/users.ts b/src/mocks/data/users.ts index 54c15f3..c292050 100644 --- a/src/mocks/data/users.ts +++ b/src/mocks/data/users.ts @@ -19,8 +19,14 @@ export const user: User & MyProfile = { stories: posts.stories, nostr_prv_key: "123123124asdfsadfsa8d7fsadfasdf", nostr_pub_key: "123124123123dfsadfsa8d7f11sadfasdf", - walletsKeys: [{ - key: "1645h234j2421zxvertw", - name: "My alby wallet key" - }] + walletsKeys: [ + { + key: "1645h234j2421zxvertw", + name: "My Alby wallet key" + }, + { + key: "6643534534534534543", + name: "My Phoenix wallet key" + }, + ] } From 0d8828860b56d1b81610f315fd43f9cb2a828b51 Mon Sep 17 00:00:00 2001 From: MTG2000 Date: Tue, 23 Aug 2022 15:02:09 +0300 Subject: [PATCH 2/7] logs --- api/functions/login/login.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/functions/login/login.js b/api/functions/login/login.js index 2a30585..698c0bb 100644 --- a/api/functions/login/login.js +++ b/api/functions/login/login.js @@ -55,6 +55,7 @@ const loginHandler = async (req, res) => { .json({ status: "OK" }) } catch (error) { + console.log(error); return res.status(400).json({ status: 'ERROR', reason: 'Invalid User Token' }) } } @@ -126,6 +127,7 @@ const loginHandler = async (req, res) => { return res.status(200).json({ status: "OK" }) } catch (error) { + console.log(error); return res.status(400).json({ status: 'ERROR', reason: 'Unexpected error happened, please try again' }) } } From b1ea5ae80613c01af4ab3efbf045b84e3488fa02 Mon Sep 17 00:00:00 2001 From: MTG2000 Date: Tue, 23 Aug 2022 15:11:19 +0300 Subject: [PATCH 3/7] fix: remove old keys before inserting new ones --- api/functions/login/login.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/api/functions/login/login.js b/api/functions/login/login.js index 698c0bb..e5b4b0c 100644 --- a/api/functions/login/login.js +++ b/api/functions/login/login.js @@ -37,19 +37,19 @@ const loginHandler = async (req, res) => { if (existingKeys.length >= 3) return res.status(400).json({ status: 'ERROR', reason: "Can only link up to 3 wallets" }) - if (!existingKeys.includes(key)) - await prisma.userKey.create({ - data: { - key, - user_id, - } - }); - // Remove old linking for this key if existing await prisma.userKey.deleteMany({ where: { key } }) + await prisma.userKey.create({ + data: { + key, + user_id, + } + }); + + return res .status(200) .json({ status: "OK" }) From f1f40aa5cb6dfc654acd38f46a4d2ee789211992 Mon Sep 17 00:00:00 2001 From: MTG2000 Date: Tue, 23 Aug 2022 15:18:49 +0300 Subject: [PATCH 4/7] remove logs --- api/functions/login/login.js | 2 -- src/features/Auth/pages/LoginPage/LoginPage.tsx | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/api/functions/login/login.js b/api/functions/login/login.js index e5b4b0c..782f195 100644 --- a/api/functions/login/login.js +++ b/api/functions/login/login.js @@ -55,7 +55,6 @@ const loginHandler = async (req, res) => { .json({ status: "OK" }) } catch (error) { - console.log(error); return res.status(400).json({ status: 'ERROR', reason: 'Invalid User Token' }) } } @@ -127,7 +126,6 @@ const loginHandler = async (req, res) => { return res.status(200).json({ status: "OK" }) } catch (error) { - console.log(error); return res.status(400).json({ status: 'ERROR', reason: 'Unexpected error happened, please try again' }) } } diff --git a/src/features/Auth/pages/LoginPage/LoginPage.tsx b/src/features/Auth/pages/LoginPage/LoginPage.tsx index 3407622..475fb7e 100644 --- a/src/features/Auth/pages/LoginPage/LoginPage.tsx +++ b/src/features/Auth/pages/LoginPage/LoginPage.tsx @@ -175,7 +175,7 @@ export default function LoginPage() { Scan this code or copy + paste it to your lightning wallet. Or click to login with your browser's wallet.

- Click to connect