Commit | Line | Data |
---|---|---|
0337d704 | 1 | /*************************************************************************** |
9f5bd98e | 2 | * Copyright (C) 2003-2010 Polytechnique.org * |
0337d704 | 3 | * http://opensource.polytechnique.org/ * |
4 | * * | |
5 | * This program is free software; you can redistribute it and/or modify * | |
6 | * it under the terms of the GNU General Public License as published by * | |
7 | * the Free Software Foundation; either version 2 of the License, or * | |
8 | * (at your option) any later version. * | |
9 | * * | |
10 | * This program is distributed in the hope that it will be useful, * | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
13 | * GNU General Public License for more details. * | |
14 | * * | |
15 | * You should have received a copy of the GNU General Public License * | |
16 | * along with this program; if not, write to the Free Software * | |
17 | * Foundation, Inc., * | |
18 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * | |
19 | ***************************************************************************/ | |
20 | ||
21 | function correctUserName() { | |
22 | var u = document.forms.login.username; | |
23 | // login with no space | |
24 | if (u.value.indexOf(' ') < 0) return true; | |
25 | var mots = u.value.split(' '); | |
26 | // jean paul.du pont -> jean-paul.du-pont | |
27 | if (u.value.indexOf('.') > 0) { u.value = mots.join('-'); return true; } | |
28 | // jean dupont -> jean.dupont | |
29 | if (mots.length == 2) { u.value = mots[0]+"."+mots[1]; return true; } | |
30 | // jean dupont 2001 -> jean.dupont.2001 | |
31 | if (mots.length == 3 && mots[2] > 1920 && mots[2] < 3000) { u.value = mots.join('.'); return true; } | |
32 | // jean de la vallee -> jean.de-la-vallee | |
33 | if (mots[1].toUpperCase() == 'DE') { u.value = mots[0]+"."+mots.join('-').substr(mots[0].length+1); return true; } | |
34 | // jean paul dupont -> jean-paul.dupont | |
35 | if (mots.length == 3 && mots[0].toUpperCase() == 'JEAN') { u.value = mots[0]+"-"+mots[1]+"."+mots[2]; return true; } | |
2b18a8ff | 36 | |
a14159bf | 37 | 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 -'); |
0337d704 | 38 | |
39 | return false; | |
40 | } | |
41 | ||
42 | function doChallengeResponse() { | |
43 | ||
44 | if (!correctUserName()) return false; | |
45 | ||
46bde4d1 | 46 | var new_pass = hash_encrypt(document.forms.login.password.value); |
2b18a8ff FB |
47 | var old_pass = hash_encrypt(document.forms.login.password.value.substr(0, 10)); |
48 | ||
0337d704 | 49 | str = document.forms.login.username.value + ":" + |
46bde4d1 | 50 | new_pass + ":" + |
0337d704 | 51 | document.forms.loginsub.challenge.value; |
52 | ||
46bde4d1 | 53 | document.forms.loginsub.response.value = hash_encrypt(str); |
79afc233 FB |
54 | if (new_pass != old_pass) { |
55 | document.forms.loginsub.xorpass.value = hash_xor(new_pass, old_pass); | |
56 | } | |
0337d704 | 57 | document.forms.loginsub.username.value = document.forms.login.username.value; |
58 | document.forms.loginsub.remember.value = document.forms.login.remember.checked; | |
59 | document.forms.loginsub.domain.value = document.forms.login.domain.value; | |
60 | document.forms.login.password.value = ""; | |
61 | document.forms.loginsub.submit(); | |
0337d704 | 62 | } |
a14159bf | 63 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |