From 049c0b946ac74c44027071d30c605a1578fe66a0 Mon Sep 17 00:00:00 2001 From: Ben Wheeler Date: Wed, 5 Feb 2020 15:48:15 -0500 Subject: [PATCH] use api instead of scratchr2 to validate usernames --- src/lib/validate.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/lib/validate.js b/src/lib/validate.js index 24e921ddd..3e734ac77 100644 --- a/src/lib/validate.js +++ b/src/lib/validate.js @@ -20,16 +20,14 @@ module.exports.validateUsernameLocally = username => { module.exports.validateUsernameRemotely = username => ( new Promise(resolve => { api({ - host: '', // not handled by API; use existing infrastructure - uri: `/accounts/check_username/${username}/` + uri: `/accounts/checkusername/${username}/` }, (err, body, res) => { if (err || res.statusCode !== 200) { resolve({requestSucceeded: false, valid: false, errMsgId: 'general.error'}); } let msg = ''; - if (body && body[0]) { - msg = body[0].msg; - } + if (body && body.msg) msg = body.msg; + else if (body && body[0]) msg = body[0].msg; switch (msg) { case 'valid username': resolve({requestSucceeded: true, valid: true});