diff --git a/converse.js b/converse.js index 0969caf26..b3d02f687 100644 --- a/converse.js +++ b/converse.js @@ -309,12 +309,14 @@ cache_otr_key: false, csi_waiting_time: 0, // Support for XEP-0352. Seconds before client is considered idle and CSI is sent out. debug: false, + default_domain: undefined, domain_placeholder: __(" e.g. conversejs.org"), // Placeholder text shown in the domain input on the registration form expose_rid_and_sid: false, forward_messages: false, hide_muc_server: false, hide_offline_users: false, jid: undefined, + locked_domain: undefined, keepalive: false, message_archiving: 'never', // Supported values are 'always', 'never', 'roster' (See https://xmpp.org/extensions/xep-0313.html#prefs ) message_carbons: false, // Support for XEP-280 @@ -6015,7 +6017,7 @@ 'label_password': __('Password:'), 'label_anon_login': __('Click here to log in anonymously'), 'label_login': __('Log In'), - 'placeholder_username': __('user@server'), + 'placeholder_username': (converse.locked_domain || converse.default_domain) && __('Username') || __('user@server'), 'placeholder_password': __('password') }) )); @@ -6053,6 +6055,11 @@ $pw_input.addClass('error'); } if (errors) { return; } + if (converse.locked_domain) { + jid = Strophe.escapeNode(jid) + '@' + converse.locked_domain; + } else if (converse.default_domain && jid.indexOf('@') === -1) { + jid = jid + '@' + converse.default_domain; + } this.connect($form, jid, password); return false; }, diff --git a/docs/CHANGES.md b/docs/CHANGES.md index b47b0fd0c..c4307d61e 100644 --- a/docs/CHANGES.md +++ b/docs/CHANGES.md @@ -5,6 +5,8 @@ - #352 When the user has manually scrolled up in a chat window, don't scroll down on chat event notifications. [jcbrand] - #524 Added `auto_join_on_invite` parameter for automatically joining chatrooms. [ben] +- #520 Set specific domain. Two new options [default_domain](https://conversejs.org/docs/html/configuration.html#default_domain) + and [locked_domain](https://conversejs.org/docs/html/configuration.html#locked_domain). [jcbrand] - #521 Not sending presence when connecting after disconnection. [jcbrand] - #535 Messages not received when room with mixed-case JID is used. [jcbrand] - #536 Presence not sent out (in cases where it should) after page refresh. [jcbrand] diff --git a/docs/source/configuration.rst b/docs/source/configuration.rst index 952ed42d0..56f0170b5 100644 --- a/docs/source/configuration.rst +++ b/docs/source/configuration.rst @@ -319,6 +319,21 @@ debug If set to true, debugging output will be logged to the browser console. +default_domain +-------------- + +* Default: ``undefined`` + +Specify a domain to act as the default for user JIDs. This allows users to log +in with only the username part of their JID, instead of the full JID. + +For example, if ``default_domain`` is ``example.org``, then the user: +``johnny@example.org`` can log in with only ``johnny``. + +JIDs with other domains are still allowed but need to be provided in full. +To specify only one domain and disallow other domains, see the `locked_domain`_ +option. + domain_placeholder ------------------ @@ -476,7 +491,12 @@ If no locale is matching available locales, the default is ``en``. Specify the locale/language. The language must be in the ``locales`` object. Refer to ``./locale/locales.js`` to see which locales are supported. -.. _`play-sounds`: +locked_domain +------------- + +* Default: ``undefined`` + +Similar to `default_domain`_ but no other domains are allowed. ping_interval ------------- @@ -489,6 +509,8 @@ You need to set the value to any positive value to enable this functionality. If you set this value to ``0`` or any negative value, il will disable this functionality. +.. _`play-sounds`: + play_sounds -----------