Mercurial > libervia-web
changeset 250:38e6211d36ca
browser_side: added auto-connection with URL parameters:
- format: http://libervia.org/login=xxx&passwd=yyy
author | souliane <souliane@mailoo.org> |
---|---|
date | Wed, 23 Oct 2013 18:33:16 +0200 |
parents | c24715dcd2f6 |
children | 24335e82fef0 |
files | libervia.py |
diffstat | 1 files changed, 20 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libervia.py Fri Nov 08 20:50:11 2013 +0100 +++ b/libervia.py Wed Oct 23 18:33:16 2013 +0200 @@ -26,6 +26,7 @@ from pyjamas.Timer import Timer from pyjamas import Window, DOM from pyjamas.JSONService import JSONProxy +from pyjamas import Location from browser_side.register import RegisterBox from browser_side.contact import ContactPanel from browser_side.base_widget import WidgetsPanel @@ -34,7 +35,7 @@ from browser_side.jid import JID from browser_side.tools import html_sanitize from sat.tools.frontends.misc import InputHistory - +from sat.tools.frontends.strings import getURLParams MAX_MBLOG_CACHE = 500 # Max microblog entries kept in memories @@ -241,6 +242,7 @@ self._entityDataUpdatedCb(jid_str, 'avatar', result['avatar']) else: self.bridge.call("getCard", None, jid_str) + def avatarError(error_data): # The jid is maybe not in our roster, we ask for the VCard self.bridge.call("getCard", None, jid_str) @@ -285,12 +287,13 @@ self._register_box = RegisterBox(self.logged) self._register_box.centerBox() self._register_box.show() + self._tryAutoConnect() else: self._register.call('isConnected', self._isConnectedCB) def _isConnectedCB(self, connected): if not connected: - self._register.call('connect', lambda x:self.logged()) + self._register.call('connect', lambda x: self.logged()) else: self.logged() @@ -315,6 +318,21 @@ self.bridge.call("getNewAccountDomain", (domain_cb, domain_eb)) + def _tryAutoConnect(self): + """This method retrieve the eventual URL parameters to auto-connect the user.""" + params = getURLParams(Window.getLocation().getSearch()) + if "login" in params: + self._register_box._form.login_box.setText(params["login"]) + self._register_box._form.login_pass_box.setFocus(True) + if "passwd" in params: + # try to connect + self._register_box._form.login_pass_box.setText(params["passwd"]) + self._register_box._form.onLogin(None) + return True + else: + # this would eventually set the browser saved password + Timer(5, lambda: self._register_box._form.login_pass_box.setFocus(True)) + def _getContactsCB(self, contacts_data): for contact in contacts_data: jid, attributes, groups = contact