# HG changeset patch # User souliane # Date 1449594679 -3600 # Node ID fad9c9f82ae3b72a5133676f2b6b8c48c563520f # Parent a6b39838353f79ceede223ad4b2d3095b9568309 browser and server sides: alert the user after he created a new profile using his XMPP account credentials diff -r a6b39838353f -r fad9c9f82ae3 src/browser/sat_browser/register.py --- a/src/browser/sat_browser/register.py Tue Dec 08 15:11:02 2015 +0100 +++ b/src/browser/sat_browser/register.py Tue Dec 08 18:11:19 2015 +0100 @@ -210,6 +210,9 @@ elif result == C.XMPP_AUTH_ERROR: # TODO: call stdui action CHANGE_XMPP_PASSWD_ID as it's done in primitivus Window.alert(_(u'Your SàT profile has been authenticated but the associated XMPP account failed to connect. Please use another SàT frontend to set another XMPP password.')) + elif result == C.PROFILE_LOGGED_REGISTERED_WITH_EXT_JID: + Window.alert(_('A profile has been created on this Libervia service using your existing XMPP account. Since you are not using our XMPP server, we can not guaranty that all the extra features (blog, directory...) will fully work.')) + self.callback() elif result == C.PROFILE_LOGGED: self.callback() elif result == C.SESSION_ACTIVE: diff -r a6b39838353f -r fad9c9f82ae3 src/common/constants.py --- a/src/common/constants.py Tue Dec 08 15:11:02 2015 +0100 +++ b/src/common/constants.py Tue Dec 08 18:11:19 2015 +0100 @@ -35,6 +35,7 @@ ALREADY_WAITING = 'ALREADY WAITING' SESSION_ACTIVE = 'SESSION ACTIVE' PROFILE_LOGGED = 'LOGGED' + PROFILE_LOGGED_REGISTERED_WITH_EXT_JID = 'LOGGED (REGISTERED WITH EXTERNAL JID)' ALREADY_EXISTS = 'ALREADY EXISTS' REGISTRATION_SUCCEED = 'REGISTRATION' INTERNAL_ERROR = 'INTERNAL ERROR' diff -r a6b39838353f -r fad9c9f82ae3 src/server/server.py --- a/src/server/server.py Tue Dec 08 15:11:02 2015 +0100 +++ b/src/server/server.py Tue Dec 08 18:11:19 2015 +0100 @@ -695,14 +695,15 @@ class WaitingRequests(dict): - def setRequest(self, request, profile): + def setRequest(self, request, profile, register_with_ext_jid=False): """Add the given profile to the waiting list. @param request (server.Request): the connection request @param profile (str): %(doc_profile)s + @param register_with_ext_jid (bool): True if we will try to register the profile with an external XMPP account credentials """ dc = reactor.callLater(BRIDGE_TIMEOUT, self.purgeRequest, profile) - self[profile] = (request, dc) + self[profile] = (request, dc, register_with_ext_jid) def purgeRequest(self, profile): """Remove the given profile from the waiting list. @@ -725,6 +726,14 @@ """ return self[profile][0] if profile in self else None + def getRegisterWithExtJid(self, profile): + """Get the value of the register_with_ext_jid parameter. + + @param profile (str): %(doc_profile)s + @return: bool or None + """ + return self[profile][2] if profile in self else None + class Register(JSONRPCMethodManager): """This class manage the registration procedure with SàT @@ -816,16 +825,18 @@ try: profile = self.sat_host.bridge.getProfileName(login) - except Exception: - # try to connect using XMPP credentials instead of SàT profile credentials + except Exception: # XXX: ProfileUnknownError wouldn't work, it's encapsulated + # try to create a new sat profile using the XMPP credentials profile = login connect_method = "asyncConnectWithXMPPCredentials" + register_with_ext_jid = True else: if profile != login or (not password and profile not in self.sat_host.empty_password_allowed_warning_dangerous_list): # profiles with empty passwords are restricted to local frontends request.write(C.PROFILE_AUTH_ERROR) request.finish() return + register_with_ext_jid = False connect_method = "asyncConnect" @@ -851,7 +862,7 @@ request.write(fault) request.finish() - self.waiting_profiles.setRequest(request, profile) + self.waiting_profiles.setRequest(request, profile, register_with_ext_jid) d = self.asyncBridgeCall(connect_method, profile, password) d.addCallbacks(lambda connected: self._logged(profile, request) if connected else None, auth_eb) @@ -907,6 +918,7 @@ - C.PROFILE_LOGGED - C.SESSION_ACTIVE """ + register_with_ext_jid = self.waiting_profiles.getRegisterWithExtJid(profile) self.waiting_profiles.purgeRequest(profile) _session = request.getSession() sat_session = ISATSession(_session) @@ -931,7 +943,7 @@ _session.notifyOnExpire(onExpire) - request.write(C.PROFILE_LOGGED) + request.write(C.PROFILE_LOGGED_REGISTERED_WITH_EXT_JID if register_with_ext_jid else C.PROFILE_LOGGED) request.finish() def jsonrpc_isConnected(self): @@ -1056,9 +1068,9 @@ """ if not profile in self.sat_host.prof_connected: return - # FIXME: manage security limit in a dedicated method - # raise an exception if it's not OK - # and read value in sat.conf + # FIXME: manage security limit in a dedicated method + # raise an exception if it's not OK + # and read value in sat.conf if security_limit >= C.SECURITY_LIMIT: log.debug(u"Ignoring action {action_id}, blocked by security limit".format(action_id=action_id)) return