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