damus.io

damus.io website
git clone git://jb55.com/damus.io
Log | Files | Refs | README | LICENSE

commit c65a6ae8dea2ceb8466aa3d96534fb8e2ce66905
parent c88bd9432024c15b4c001db74700d06adaa3ef95
Author: Daniel D’Aquino <daniel@daquino.me>
Date:   Tue, 23 Apr 2024 00:59:21 +0000

Fix login issue where the user would be stuck before getting the OTP if their profile was not found on the relay

Some users reported that they were unable to login. This happened when
their profiles could not be found on the relay preconfigured on the
website (The Damus relay).

This commit fixes that by removing the offending condition that would
require a profile to be found in order to proceed with the login.

Furthermore, this commit also adds a new environment variable that
allows the default Nostr relay address to be modified (which is useful
for testing or configuration purposes)

Testing
-------

Damus API: bfe6c4240a0b3729724162896f0024a963586f7c
Damus website: This commit
Configuration: Local testing configuration, with the relay address modified to a `localhost` relay (which is empty and does not have any profiles in it)
Procedure:
1. Paste the npub of a user that exists in the local server.
2. Press "continue". Make sure that OTP screen appears.
3. If it does, continue with the rest of the login

Repro:
  - Damus API: bfe6c4240a0b3729724162896f0024a963586f7c
  - Damus website: c88bd9432024c15b4c001db74700d06adaa3ef95
  - Result: ISSUE REPRODUCED ("Continue" button does not work)

Fix test:
  - Damus API: bfe6c4240a0b3729724162896f0024a963586f7c
  - Damus website: This commit
  - Result: PASS

Changelog-Fixed: Fix login issue where continue button on the login screen would not do anything
Closes: https://github.com/damus-io/damus/issues/2164
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
Reviewed-by: William Casarin <jb55@jb55.com>
Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Msrc/components/sections/PurpleLogin.tsx | 4++--
Msrc/utils/PurpleUtils.ts | 2+-
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/components/sections/PurpleLogin.tsx b/src/components/sections/PurpleLogin.tsx @@ -65,7 +65,7 @@ export function PurpleLogin() { } const beginLogin = async () => { - if (!pubkey || !profile) { + if (!pubkey || !existingAccountInfo) { return } const response = await fetch(process.env.NEXT_PUBLIC_PURPLE_API_BASE_URL + "/accounts/" + pubkey + "/request-otp", { @@ -84,7 +84,7 @@ export function PurpleLogin() { } const completeOTP = async () => { - if (!pubkey || !profile || !otp) { + if (!pubkey || !existingAccountInfo || !otp) { return } const response = await fetch(process.env.NEXT_PUBLIC_PURPLE_API_BASE_URL + "/accounts/" + pubkey + "/verify-otp", { diff --git a/src/utils/PurpleUtils.ts b/src/utils/PurpleUtils.ts @@ -55,7 +55,7 @@ catch (e) { } const getProfileEvent = async (pubkey: string): Promise<NostrEvent | null> => { -const relay = await Relay.connect('wss://relay.damus.io') +const relay = await Relay.connect(process.env.NEXT_PUBLIC_NOSTR_RELAY || 'wss://relay.damus.io') const events: Array<NostrEvent> = [] return new Promise((resolve, reject) => {