]> git.mxchange.org Git - friendica-addons.git/blob - jappixmini/jappix/js/httpauth.js
Merge remote branch 'upstream/master'
[friendica-addons.git] / jappixmini / jappix / js / httpauth.js
1 /*
2
3 Jappix - An open social platform
4 These are the http-auth JS scripts for Jappix
5
6 -------------------------------------------------
7
8 License: AGPL
9 Author: Vanaryon
10 Last revision: 16/11/10
11
12 */
13
14 // Replies to a HTTP request
15 function requestReply(value, xml) {
16         // We parse the xml content
17         var from = fullXID(getStanzaFrom(xml));
18         var confirm = $(xml.getNode()).find('confirm');
19         var xmlns = confirm.attr('xmlns');
20         var id = confirm.attr('id');
21         var method = confirm.attr('method');
22         var url = confirm.attr('url');
23         
24         // We generate the reply message
25         var aMsg = new JSJaCMessage();
26         aMsg.setTo(from);
27         
28         // If "no"
29         if(value == 'no') {
30                 aMsg.setType('error');
31                 aMsg.appendNode('error', {'code': '401', 'type': 'auth'});
32         }
33         
34         // We set the confirm node
35         aMsg.appendNode('confirm', {'xmlns': xmlns, 'url': url, 'id': id, 'method': method});
36         
37         // We send the message
38         con.send(aMsg, handleErrorReply);
39         
40         logThis('Replying HTTP auth request: ' + from, 3);
41 }