Skip to content

Instantly share code, notes, and snippets.

@giastfader
Created February 23, 2015 23:29
Show Gist options
  • Select an option

  • Save giastfader/1296d9d6081bf5026729 to your computer and use it in GitHub Desktop.

Select an option

Save giastfader/1296d9d6081bf5026729 to your computer and use it in GitHub Desktop.
BaasBox: checks if a username exists
/* 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