浏览代码

Add `jid` method to converse API, to retrieve the user's JID.

JC Brand 9 年之前
父节点
当前提交
c243aba98f
共有 2 个文件被更改,包括 13 次插入0 次删除
  1. 10 0
      docs/source/development.rst
  2. 3 0
      src/converse-api.js

+ 10 - 0
docs/source/development.rst

@@ -400,6 +400,16 @@ The "user" grouping
 
 This grouping collects API functions related to the current logged in user.
 
+jid
+~~~
+
+Return's the current user's full JID (Jabber ID).
+
+.. code-block:: javascript
+
+    converse.user.jid()
+    // Returns for example jc@opkode.com/conversejs-351236
+
 login
 ~~~~~
 

+ 3 - 0
src/converse-api.js

@@ -34,6 +34,9 @@
             },
         },
         'user': {
+            'jid': function () {
+                return converse.connection.jid;
+            },
             'login': function (credentials) {
                 converse.initConnection();
                 converse.logIn(credentials);