comparison src/browser/sat_browser/register.py @ 851:77a494f13118

browser (register): improve some regex after Link Mauve's comments: - accept . and + in the email address and external JID's user - it is still very restrictive, but better than before - TODO: check email reception or JID existence instead
author souliane <souliane@mailoo.org>
date Sat, 16 Jan 2016 10:48:31 +0100
parents 7dafa5ee809a
children 54f6c5b86a87
comparison
equal deleted inserted replaced
850:c64c039bb403 851:77a494f13118
188 # XXX: for now libervia forces the creation to lower case 188 # XXX: for now libervia forces the creation to lower case
189 self.register_login_box.setText(self.register_login_box.getText().lower()) 189 self.register_login_box.setText(self.register_login_box.getText().lower())
190 if not self.checkLogin(self.register_login_box.getText()): 190 if not self.checkLogin(self.register_login_box.getText()):
191 self.register_warning_msg.setHTML(_('Invalid login, valid characters<br>are a-z A-Z 0-9 _ -')) 191 self.register_warning_msg.setHTML(_('Invalid login, valid characters<br>are a-z A-Z 0-9 _ -'))
192 elif not self.checkEmail(self.email_box.getText()): 192 elif not self.checkEmail(self.email_box.getText()):
193 self.register_warning_msg.setHTML(_('Invalid email address')) 193 self.register_warning_msg.setHTML(_('Invalid email address<br>(or not accepted yet)'))
194 elif len(self.register_pass_box.getText()) < C.PASSWORD_MIN_LENGTH: 194 elif len(self.register_pass_box.getText()) < C.PASSWORD_MIN_LENGTH:
195 self.register_warning_msg.setHTML(_('Your password must contain<br>at least %d characters.') % C.PASSWORD_MIN_LENGTH) 195 self.register_warning_msg.setHTML(_('Your password must contain<br>at least %d characters.') % C.PASSWORD_MIN_LENGTH)
196 else: 196 else:
197 self.register_warning_msg.setHTML("") 197 self.register_warning_msg.setHTML("")
198 self.submit_type.setValue('register') 198 self.submit_type.setValue('register')
240 240
241 @param text (unicode) 241 @param text (unicode)
242 @return bool 242 @return bool
243 """ 243 """
244 # FIXME: Pyjamas re module is not stable so we use pure JS instead 244 # FIXME: Pyjamas re module is not stable so we use pure JS instead
245 # FIXME: login is restricted to this regex until we fix the account creation
245 JS("""return /^(\w|-)+$/.test(text);""") 246 JS("""return /^(\w|-)+$/.test(text);""")
246 247
247 def checkEmail(self, text): 248 def checkEmail(self, text):
248 """Check if the given text is a valid email address. 249 """Check if the given text is a valid email address.
249 250
250 @param text (unicode) 251 @param text (unicode)
251 @return bool 252 @return bool
252 """ 253 """
253 # FIXME: Pyjamas re module is not stable so we use pure JS instead 254 # FIXME: Pyjamas re module is not stable so we use pure JS instead
254 JS("""return /^(\w|-)+@(\w|-)+\.(\w|-)+$/.test(text);""") 255 # FIXME: send a message to validate the email instead of using a bad regex
256 JS("""return /^(\w|-|\.|\+)+@(\w|-)+\.(\w|-)+$/.test(text);""")
255 257
256 def checkJID(self, text): 258 def checkJID(self, text):
257 """Check if the given text is a valid JID. 259 """Check if the given text is a valid JID.
258 260
259 @param text (unicode) 261 @param text (unicode)
260 @return bool 262 @return bool
261 """ 263 """
262 # FIXME: Pyjamas re module is not stable so we use pure JS instead 264 # FIXME: Pyjamas re module is not stable so we use pure JS instead
263 JS("""return /^(\w|-)+(@(\w|-)+\.(\w|-)+)?$/.test(text);""") 265 # FIXME: this regex is too restrictive for people using external XMPP account
266 JS("""return /^(\w|-|\.|\+)+(@(\w|-)+\.(\w|-)+)?$/.test(text);""")
264 267
265 268
266 class RegisterBox(PopupPanel): 269 class RegisterBox(PopupPanel):
267 270
268 def __init__(self, callback, *args, **kwargs): 271 def __init__(self, callback, *args, **kwargs):