Created
February 23, 2015 23:29
-
-
Save giastfader/1296d9d6081bf5026729 to your computer and use it in GitHub Desktop.
BaasBox: checks if a username exists
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* script: bb.check_user_exists */ | |
| /* This script endpoint: /plugin/bb.check_user_exists */ | |
| /*usage: | |
| GET /plugin/bb.check_user_exists?username=<username_to_check> | |
| /* returns error 404 if the specified username does not exists, otherwise it returns the public profile */ | |
| http().get(function(req){ | |
| var user=req.queryString.username[0]; | |
| var res=Box.Users.find({ | |
| where:"user.name = ?", | |
| params:user | |
| }); | |
| if (res.length==0) return {status:404}; | |
| return {status: 200,content:res[0]}; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment