Commit 78989f1f authored by Remi Rampin's avatar Remi Rampin

Add /api/check_user endpoint

parent a9f418ed
......@@ -90,6 +90,7 @@ def make_app(config, debug=False, xsrf_cookies=True):
export.ExportHighlightsDoc, name='export_highlights_doc'),
# API
URLSpec('/api/check_user', api.CheckUser),
URLSpec('/api/project/([0-9]+)', api.ProjectMeta),
URLSpec('/api/project/([0-9]+)/document/new', api.DocumentAdd),
URLSpec('/api/project/([0-9]+)/document/([0-9]+)',
......
......@@ -40,6 +40,20 @@ def api_auth(method):
return wrapper
class CheckUser(BaseHandler):
PROM_API.labels('check_user').inc(0)
@api_auth
def post(self):
PROM_API.labels('check_user').inc()
login = self.get_json()['login']
if validate.user_login(login):
user = self.db.query(database.User).get(login)
if user is not None:
return self.send_json({'exists': True})
return self.send_json({'exists': False})
class ProjectMeta(BaseHandler):
PROM_API.labels('project_meta').inc(0)
......
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