Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Add a route for determining who you are #2668

Merged
merged 2 commits into from
Nov 14, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions synapse/rest/client/v2_alpha/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,22 @@ def on_POST(self, request):
defer.returnValue((200, {}))


class WhoamiRestServlet(RestServlet):
PATTERNS = client_v2_patterns("/account/whoami$")

def __init__(self, hs):
super(WhoamiRestServlet, self).__init__()
self.auth = hs.get_auth()

@defer.inlineCallbacks
def on_GET(self, request):
yield run_on_reactor()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is redundant, I think.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was. Updated!


requester = yield self.auth.get_user_by_req(request)

defer.returnValue((200, {'user_id': requester.user.to_string()}))


def register_servlets(hs, http_server):
EmailPasswordRequestTokenRestServlet(hs).register(http_server)
MsisdnPasswordRequestTokenRestServlet(hs).register(http_server)
Expand All @@ -391,3 +407,4 @@ def register_servlets(hs, http_server):
MsisdnThreepidRequestTokenRestServlet(hs).register(http_server)
ThreepidRestServlet(hs).register(http_server)
ThreepidDeleteRestServlet(hs).register(http_server)
WhoamiRestServlet(hs).register(http_server)