diff options
author | Zara Gebru <zgebru@thoughtworks.com> | 2016-04-06 14:33:57 +0200 |
---|---|---|
committer | Zara Gebru <zgebru@thoughtworks.com> | 2016-04-06 15:41:04 +0200 |
commit | dc389b7a1424ca39a88b783f77006536031d93bd (patch) | |
tree | c34ca93ea18203814d35491af63be90671860b2c /service/pixelated | |
parent | 17337680ace5738a5f3e5a003bb9ab953eea8f46 (diff) |
Issue #292: add fingerprint to user settings resource
Diffstat (limited to 'service/pixelated')
-rw-r--r-- | service/pixelated/resources/user_settings_resource.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/service/pixelated/resources/user_settings_resource.py b/service/pixelated/resources/user_settings_resource.py index 5b3f0051..38997b30 100644 --- a/service/pixelated/resources/user_settings_resource.py +++ b/service/pixelated/resources/user_settings_resource.py @@ -14,7 +14,10 @@ # You should have received a copy of the GNU Affero General Public License # along with Pixelated. If not, see <http://www.gnu.org/licenses/>. -from pixelated.resources import respond_json, BaseResource +from pixelated.resources import respond_json_deferred, BaseResource +from twisted.web import server + +FINGERPRINT_NOT_FOUND = 'Fingerprint not found' class UserSettingsResource(BaseResource): @@ -25,4 +28,16 @@ class UserSettingsResource(BaseResource): def render_GET(self, request): _account_email = self.mail_service(request).account_email - return respond_json({'account_email': _account_email}, request) + + def finish_request(key): + _fingerprint = key.fingerprint + respond_json_deferred({'account_email': _account_email, 'fingerprint': _fingerprint}, request) + + def key_not_found(_): + respond_json_deferred({'account_email': _account_email, 'fingerprint': FINGERPRINT_NOT_FOUND}, request) + + d = self.keymanager(request).fetch_key(_account_email) + d.addCallback(finish_request) + d.addErrback(key_not_found) + + return server.NOT_DONE_YET |