Unverified Commit 9b79fd7e authored by Benjamin Wheeler's avatar Benjamin Wheeler Committed by GitHub

Merge pull request #3507 from picklesrus/scratchr2-checkuser

Switch to using scratchr2 check_username endpoint instead of api. 
parents b8450100 c2004d0f
...@@ -18,12 +18,17 @@ module.exports.validateUsernameLocally = username => { ...@@ -18,12 +18,17 @@ module.exports.validateUsernameLocally = username => {
module.exports.validateUsernameRemotely = username => ( module.exports.validateUsernameRemotely = username => (
new Promise(resolve => { new Promise(resolve => {
api({ api({
uri: `/accounts/checkusername/${username}/` host: '', // not handled by API; use existing infrastructure
uri: `/accounts/check_username/${username}/`
}, (err, body, res) => { }, (err, body, res) => {
if (err || res.statusCode !== 200) { if (err || res.statusCode !== 200) {
resolve({requestSucceeded: false, valid: false, errMsgId: 'general.error'}); resolve({requestSucceeded: false, valid: false, errMsgId: 'general.error'});
} }
switch (body.msg) { let msg = '';
if (body && body[0]) {
msg = body[0].msg;
}
switch (msg) {
case 'valid username': case 'valid username':
resolve({requestSucceeded: true, valid: true}); resolve({requestSucceeded: true, valid: true});
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment