mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-26 17:16:11 -05:00
use api instead of scratchr2 to validate usernames
This commit is contained in:
parent
6e543b0c55
commit
049c0b946a
1 changed files with 3 additions and 5 deletions
|
@ -20,16 +20,14 @@ module.exports.validateUsernameLocally = username => {
|
||||||
module.exports.validateUsernameRemotely = username => (
|
module.exports.validateUsernameRemotely = username => (
|
||||||
new Promise(resolve => {
|
new Promise(resolve => {
|
||||||
api({
|
api({
|
||||||
host: '', // not handled by API; use existing infrastructure
|
uri: `/accounts/checkusername/${username}/`
|
||||||
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'});
|
||||||
}
|
}
|
||||||
let msg = '';
|
let msg = '';
|
||||||
if (body && body[0]) {
|
if (body && body.msg) msg = body.msg;
|
||||||
msg = body[0].msg;
|
else if (body && body[0]) msg = body[0].msg;
|
||||||
}
|
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case 'valid username':
|
case 'valid username':
|
||||||
resolve({requestSucceeded: true, valid: true});
|
resolve({requestSucceeded: true, valid: true});
|
||||||
|
|
Loading…
Reference in a new issue