aboutsummaryrefslogtreecommitdiffstats
path: root/lib/register.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-12-29 09:08:27 +0000
committerAdam Soltys <[email protected]>2023-12-29 09:08:35 +0000
commitf584d7a56762d19ac6c1f5eda87cfb26816d5d57 (patch)
treedca37600e33dd3319cbc5d7e70ab1c70bd14830d /lib/register.js
parentcb38551cc4ec392911d18dda9b5a9fe97087ad61 (diff)
downloadcoinos-server-f584d7a56762d19ac6c1f5eda87cfb26816d5d57.tar.gz
coinos-server-f584d7a56762d19ac6c1f5eda87cfb26816d5d57.zip
migrate in more places
Diffstat (limited to 'lib/register.js')
-rw-r--r--lib/register.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/register.js b/lib/register.js
index 487413a8..a1489d89 100644
--- a/lib/register.js
+++ b/lib/register.js
@@ -4,7 +4,7 @@ import { authenticator } from "otplib";
import bcrypt from "bcrypt";
import { l, warn } from "$lib/logging";
import { v4 } from "uuid";
-import { s, g } from "$lib/db";
+import { s, g, archive } from "$lib/db";
import { got } from "got";
export default async (user, ip, requireChallenge) => {
@@ -17,7 +17,9 @@ export default async (user, ip, requireChallenge) => {
let id = v4();
user.id = id;
- let exists = await g(`user:${username}`);
+ let exists =
+ (await g(`user:${username}`)) || (await archive.get(`user:${username}`));
+
if (exists) throw new Error(`Username ${username} taken`);
if (password) {
@@ -28,9 +30,11 @@ export default async (user, ip, requireChallenge) => {
if (config.ipregistry) {
try {
let {
- location: { country: { code } },
+ location: {
+ country: { code },
+ },
} = await got(
- `https://api.ipregistry.co/${ip}?key=${config.ipregistry}&fields=location.country.code`,
+ `https://api.ipregistry.co/${ip}?key=${config.ipregistry}&fields=location.country.code`
).json();
user.currency = countries[code];