aboutsummaryrefslogtreecommitdiffstats
path: root/lib/register.js
diff options
context:
space:
mode:
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];