bug 302 : accepter les espaces dans le login
authorPascal Corpet <pascal.corpet@m4x.org>
Mon, 23 May 2005 16:13:50 +0000 (16:13 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:29:01 +0000 (23:29 +0200)
git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-654

ChangeLog
htdocs/javascript/do_challenge_response.js

index 8c00627..9f9c28a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,9 @@ New :
 
 Bug/Wish :
 
+       * Core :
+               - #302: accept spaces in login.                                                                         -Car
+               
        * Fiche :
                - #308: organizing layout                                                                                       -Car
 
index f5c24ce..233bf62 100644 (file)
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                *
  ***************************************************************************/
 
+function correctUserName() {
+    var u = document.forms.login.username;
+    // login with no space
+    if (u.value.indexOf(' ') < 0) return true;
+    var mots = u.value.split(' ');
+    // jean paul.du pont -> jean-paul.du-pont
+    if (u.value.indexOf('.') > 0) { u.value = mots.join('-'); return true; }
+    // jean dupont  -> jean.dupont
+    if (mots.length == 2) { u.value = mots[0]+"."+mots[1]; return true; }
+    // jean dupont 2001 -> jean.dupont.2001
+    if (mots.length == 3 && mots[2] > 1920 && mots[2] < 3000) { u.value = mots.join('.'); return true; }
+    // jean de la vallee -> jean.de-la-vallee
+    if (mots[1].toUpperCase() == 'DE') { u.value = mots[0]+"."+mots.join('-').substr(mots[0].length+1); return true; }
+    // jean paul dupont -> jean-paul.dupont
+    if (mots.length == 3 && mots[0].toUpperCase() == 'JEAN') { u.value = mots[0]+"-"+mots[1]+"."+mots[2]; return true; }
+    
+    alert('Ton email ne doit pas contenir de blanc.\nLe format standard est\n\nprenom.nom.promotion\n\nSi ton nom ou ton prenom est composé,\nsépare les mots par des -');
+
+    return false;
+}
+
 function doChallengeResponse() {
+
+    if (!correctUserName()) return false;
+
     str = document.forms.login.username.value + ":" +
         MD5(document.forms.login.password.value) + ":" +
         document.forms.loginsub.challenge.value;
@@ -29,4 +53,5 @@ function doChallengeResponse() {
     document.forms.loginsub.domain.value = document.forms.login.domain.value;
     document.forms.login.password.value = "";
     document.forms.loginsub.submit();
+
 }