From 60c8386b63fe526f881120028dc46f1fd150bf72 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Sun, 27 Mar 2016 14:27:23 +0200 Subject: Added the test_token API method. This API method checks whether the provided token is valid or not. --- fbin.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fbin.py b/fbin.py index 138ea64..fdb8187 100755 --- a/fbin.py +++ b/fbin.py @@ -553,6 +553,14 @@ class Application(object): except: pass data['status'] = True + elif method == 'test_token': + try: + user = self.jab.get_user_by_token(form['token'].value, settings.jab_identifier, environ['REMOTE_ADDR']) + except jab.client.InvalidCredentialsError: + return error('Invalid token') + except: + return error('Error fetching user data') + data['status'] = True else: data['message'] = 'Unknown method "%s"' start_response('200 OK', [('Content-Type', 'application/json')]) -- cgit v1.2.3