Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scratch-www
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
scratch-www
Commits
049c0b94
Commit
049c0b94
authored
Feb 05, 2020
by
Ben Wheeler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use api instead of scratchr2 to validate usernames
parent
6e543b0c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
5 deletions
+3
-5
src/lib/validate.js
src/lib/validate.js
+3
-5
No files found.
src/lib/validate.js
View file @
049c0b94
...
...
@@ -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
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment