From cf1574d6906b99b136bb0c03d7f7092f131cc52e Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Tue, 23 May 2017 10:37:26 +0100 Subject: [PATCH] MatrixClient: add getUserId() ... I'm amazed we got this far without it. --- src/client.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/client.js b/src/client.js index 4de449256..4b9242429 100644 --- a/src/client.js +++ b/src/client.js @@ -168,6 +168,18 @@ function MatrixClient(opts) { utils.inherits(MatrixClient, EventEmitter); utils.extend(MatrixClient.prototype, MatrixBaseApis.prototype); +/** + * Get the user-id of the logged-in user + * + * @return {?string} MXID for the logged-in user, or null if not logged in + */ +MatrixClient.prototype.getUserId = function() { + if (this.credentials && this.credentials.userId) { + return this.credentials.userId; + } + return null; +}; + /** * Get the domain for this client's MXID * @return {?string} Domain of this MXID