aboutsummaryrefslogtreecommitdiffstats
path: root/webclient
diff options
context:
space:
mode:
authorZaran <zaran.krleza@gmail.com>2011-05-14 01:03:22 +0200
committerZaran <zaran.krleza@gmail.com>2011-05-14 01:03:22 +0200
commita7adb48bae64720345440147e661b0369028b267 (patch)
treeba65d4161fa3fcc9053fc2806711f60e697d11aa /webclient
parent368ada44db571c46deea674eadd410ac9bc47ebc (diff)
downloadalias-a7adb48bae64720345440147e661b0369028b267.tar.gz
On connection get the user alias information and decrypt his private key
Diffstat (limited to 'webclient')
-rw-r--r--webclient/lib/alias.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/webclient/lib/alias.js b/webclient/lib/alias.js
index f5945d7..e8174c0 100644
--- a/webclient/lib/alias.js
+++ b/webclient/lib/alias.js
@@ -18,6 +18,31 @@ var Alias = {
connection: null,
/**
+ * Send initialization request to the component
+ */
+ getInit: function() {
+ var init = $iq({to: server_component, type:'get'});
+ init.c('query',{xmlns:'jaber:iq:register'});
+ Alias.connection.sendIQ(init, onInit);
+ },
+
+ /**
+ * Receive initialization data
+ */
+ onInit: function(iq) {
+
+ if ($(iq).find('query > registered').length() === 0){
+ // user is registered, get the info from the form
+ var form = $(iq).find('query > x');
+ this.pubkey = form.find('field[var="pubkey"] > value');
+ this.salt = form.find('field[var="pubkey"] > value');
+ var privkey = form.find('field[var="pubkey"] > value');
+ var salt = form.find('field[var="salt"] > value');
+ this.privkey = sjcl.decrypt(Alias.connection.pass, privkey, {salt: salt});
+ }
+ },
+
+ /**
* Send a roster request to server
*/
getRoster: function() {
@@ -212,6 +237,7 @@ var Alias = {
*/
onConnect: function() {
Alias.getRoster();
+ Alias.getInit();
// hide the login dialog and load the interface
$('#login').hide();