|
@@ -74,8 +74,25 @@ const plugin = {
|
|
|
|
|
|
buildResponse(responseType) {
|
|
|
const httpAuthData = this.model.attributes.data;
|
|
|
- const response = httpAuthData['response'];
|
|
|
- let iqType = 'get';
|
|
|
+ let stanzaType;
|
|
|
+ let response;
|
|
|
+ if (httpAuthData.stanzaType === 'message') {
|
|
|
+ stanzaType = responseType === 'refuse' ? 'error' : 'normal';
|
|
|
+ response = converse.env.$msg({
|
|
|
+ from: httpAuthData.to, // inverse from and to
|
|
|
+ to: httpAuthData.from, // inverse from and to
|
|
|
+ type: stanzaType,
|
|
|
+ });
|
|
|
+ response.c('thread').t(httpAuthData['thread']).up();
|
|
|
+ } else {
|
|
|
+ stanzaType = responseType === 'refuse' ? 'error' : 'result';
|
|
|
+ response = converse.env.$iq({
|
|
|
+ from: httpAuthData.to, // inverse from and to
|
|
|
+ to: httpAuthData.from, // inverse from and to
|
|
|
+ id: httpAuthData.iqId,
|
|
|
+ type: stanzaType,
|
|
|
+ });
|
|
|
+ };
|
|
|
response.c('confirm', {
|
|
|
'xmlns': 'http://jabber.org/protocol/http-auth',
|
|
|
'id': httpAuthData['id'], 'method': httpAuthData['method'],
|
|
@@ -84,10 +101,6 @@ const plugin = {
|
|
|
if (responseType === 'refuse') {
|
|
|
response.c('error', { 'code': '401', 'type': 'auth' });
|
|
|
response.c('not-authorized', { 'xmlns': 'urn:ietf:params:xml:xmpp-stanzas' });
|
|
|
- iqType = 'error';
|
|
|
- }
|
|
|
- if (httpAuthData['stanzaType'] === 'iq') {
|
|
|
- response = response.attrs({ type: iqType });
|
|
|
}
|
|
|
_converse.api.send(response);
|
|
|
},
|
|
@@ -108,6 +121,7 @@ const plugin = {
|
|
|
xmlns: confirm.getAttribute('xmlns'),
|
|
|
method: confirm.getAttribute('method'),
|
|
|
id: confirm.getAttribute('id'),
|
|
|
+ iqId:stanza.getAttribute('id'),
|
|
|
url: confirm.getAttribute('url'),
|
|
|
from: stanza.getAttribute('from'),
|
|
|
to: stanza.getAttribute('to'),
|
|
@@ -115,26 +129,9 @@ const plugin = {
|
|
|
message: stanza,
|
|
|
stanzaType: stanza.localName
|
|
|
};
|
|
|
- let httpAuthMessage;
|
|
|
if (stanza.localName === 'message') {
|
|
|
- httpAuthMessage = converse.env.$msg({
|
|
|
- from: _converse.jid,
|
|
|
- to: stanza.getAttribute('from'),
|
|
|
- type: "normal",
|
|
|
- });
|
|
|
- const thread = stanza.getElementsByTagName('thread')[0].textContent;
|
|
|
- httpAuthMessage.c('thread').t(thread).up();
|
|
|
- httpAuthData['response'] = httpAuthMessage;
|
|
|
- } else {
|
|
|
- httpAuthMessage = converse.env.$iq({
|
|
|
- from: _converse.jid,
|
|
|
- to: stanza.getAttribute('from'),
|
|
|
- id: stanza.getAttribute('id'),
|
|
|
- type: 'error',
|
|
|
- });
|
|
|
- httpAuthData['response'] = httpAuthMessage;
|
|
|
+ httpAuthData['thread'] = stanza.getElementsByTagName('thread')[0].textContent;
|
|
|
}
|
|
|
-
|
|
|
const confirmDialog = new httpAuthDialog({ 'model': new Model({ view: _converse.rosterview, data: httpAuthData }) });
|
|
|
confirmDialog.show();
|
|
|
}
|