aboutsummaryrefslogtreecommitdiffstats
path: root/routes
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2020-11-11 00:18:12 -0800
committerAdam Soltys <[email protected]>2020-11-11 00:18:12 -0800
commit52ca1e9feac644f6ec4364bf60bf1c3f6bf748ad (patch)
treee9511d5676eb1049f23ec916552b2d6a2a0d4c39 /routes
parentdc4916ad8bf7ef1fd2152b7577905bf8e8695961 (diff)
downloadcoinos-server-52ca1e9feac644f6ec4364bf60bf1c3f6bf748ad.tar.gz
coinos-server-52ca1e9feac644f6ec4364bf60bf1c3f6bf748ad.zip
check for existing lnurl auth key user
Diffstat (limited to 'routes')
-rw-r--r--routes/lnurl.js20
1 files changed, 13 insertions, 7 deletions
diff --git a/routes/lnurl.js b/routes/lnurl.js
index d978e50d..006ee0c9 100644
--- a/routes/lnurl.js
+++ b/routes/lnurl.js
@@ -302,13 +302,19 @@ lnurlServer.bindToHook(
if (!user) {
let ip =
req.headers["x-forwarded-for"] || req.connection.remoteAddress;
- user = await register(
- {
- username: key.substr(0, 8),
- password: key
- },
- ip
- );
+
+ let username = `satoshi-${key.substr(0, 12)}`;
+ let existing = await db.User.findOne({ where: { username } });
+ if (existing) user = existing;
+ else {
+ user = await register(
+ {
+ username,
+ password: key
+ },
+ ip
+ );
+ }
}
({ username } = user);