summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2016-03-27 14:27:23 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2016-03-27 14:31:59 +0200
commit60c8386b63fe526f881120028dc46f1fd150bf72 (patch)
treebf37525c5848113e6959089cf5b57beb203e30c6
parent0352e45513762cbcf7f8441a7073be27a4293bc8 (diff)
Added the test_token API method.
This API method checks whether the provided token is valid or not.
-rwxr-xr-xfbin.py8
1 files changed, 8 insertions, 0 deletions
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')])