Index: trunk/extensions/SignupAPI/includes/ApiValidateSignup.php |
— | — | @@ -25,21 +25,22 @@ |
26 | 26 | case "username": |
27 | 27 | $mUser = User::newFromName( $params['inputVal'], 'creatable' ); |
28 | 28 | if ( !is_object( $mUser ) ) { |
29 | | - $result['result'] = wfMsg( 'signupapi-noname' ); |
30 | | - $result['icon'] = 'MW-Icon-AlertMark.png'; |
| 29 | + $result['result'] = wfMsg( 'signupapi-noname' ); |
| 30 | + $result['icon'] = 'MW-Icon-AlertMark.png'; |
31 | 31 | } |
32 | 32 | |
33 | 33 | if ( 0 != $mUser->idForName() ) { |
34 | | - $result['result'] = wfMsg( 'signupapi-userexists' ); |
35 | | - $result['icon'] = "MW-Icon-NoMark.png"; |
| 34 | + $result['result'] = wfMsg( 'signupapi-userexists' ); |
| 35 | + $result['icon'] = "MW-Icon-NoMark.png"; |
36 | 36 | } else { |
37 | | - $result['result'] = wfMsg( 'signupapi-ok' ); |
38 | | - $result['icon'] = "MW-Icon-CheckMark.png"; |
| 37 | + $result['result'] = wfMsg( 'signupapi-ok' ); |
| 38 | + $result['icon'] = "MW-Icon-CheckMark.png"; |
39 | 39 | } |
40 | 40 | break; |
41 | 41 | |
42 | 42 | case "email" : |
43 | | - if ( $valid = User::isValidEmailAddr( $params['inputVal'] ) ) { |
| 43 | + $valid = User::isValidEmailAddr( $params['inputVal'] ); |
| 44 | + if ( $valid ) { |
44 | 45 | $result['result']= wfMsg( 'signupapi-ok' ); |
45 | 46 | $result['icon'] = "MW-Icon-CheckMark.png"; |
46 | 47 | } else { |
— | — | @@ -70,7 +71,7 @@ |
71 | 72 | |
72 | 73 | public function getAllowedParams() { |
73 | 74 | return array( |
74 | | - 'field' => null, |
| 75 | + 'field' => null, |
75 | 76 | 'inputVal' => null, |
76 | 77 | 'password' => null, |
77 | 78 | 'retype' => null, |
Index: trunk/extensions/SignupAPI/includes/ApiSignup.php |
— | — | @@ -27,10 +27,10 @@ |
28 | 28 | 'wpRetype' => $params['retype'], |
29 | 29 | 'wpEmail' => $params['email'], |
30 | 30 | 'wpDomain' => $params['domain'], |
31 | | - 'wpReason' => $params['realname'], |
32 | | - 'wpSourceAction' => $params['source_action'], |
33 | | - 'wpSourceNS' => $params['source_ns'], |
34 | | - 'wpSourceArticle' => $params['source_article'], |
| 31 | + 'wpReason' => $params['realname'], |
| 32 | + 'wpSourceAction' => $params['source_action'], |
| 33 | + 'wpSourceNS' => $params['source_ns'], |
| 34 | + 'wpSourceArticle' => $params['source_article'], |
35 | 35 | 'wpRemember' => '' |
36 | 36 | ) ); |
37 | 37 | |
Index: trunk/extensions/SignupAPI/includes/SignupAPI.hooks.php |
— | — | @@ -79,7 +79,6 @@ |
80 | 80 | 'href' => SkinTemplate::makeSpecialUrl( 'UserSignup', "$returnto&type=signup&wpSourceAction=$sourceAction&wpSourceNS=$sourceNS&wpSourceArticle=$sourceArticle" ), |
81 | 81 | 'active' => $title->isSpecial( 'Userlogin' ) && $is_signup |
82 | 82 | ); |
83 | | - |
84 | 83 | if ( substr( $wgServer, 0, 5 ) === 'http:' && $wgSecureLogin ) { |
85 | 84 | $title = SpecialPage::getTitleFor( 'UserSignup' ); |
86 | 85 | $https_url = preg_replace( '/^http:/', 'https:', $title->getFullURL( "type=signup" ) ); |
Index: trunk/extensions/SignupAPI/includes/SpecialUserSignup.php |
— | — | @@ -243,6 +243,8 @@ |
244 | 244 | |
245 | 245 | /** |
246 | 246 | * @private |
| 247 | + * |
| 248 | + * @return User|int If int, it is a returned constant |
247 | 249 | */ |
248 | 250 | function addNewAccountInternal() { |
249 | 251 | global $wgUser; |
— | — | @@ -905,6 +907,10 @@ |
906 | 908 | } |
907 | 909 | } |
908 | 910 | |
| 911 | + /** |
| 912 | + * @param $tempUser User |
| 913 | + * @return bool |
| 914 | + */ |
909 | 915 | private function addToSourceTracking( $tempUser ) { |
910 | 916 | $sourcetracking_data = array( |
911 | 917 | 'userid' => $tempUser->getId(), |
Index: trunk/extensions/SignupAPI/includes/verification.js |
— | — | @@ -1,63 +1,61 @@ |
2 | 2 | //setup verification fields on the form |
3 | 3 | |
4 | 4 | function validateInput( fieldtype,fieldid ) { |
5 | | - var inputVal = document.getElementById(fieldid).value; |
6 | | - var valresult = document.getElementById(fieldid+'val'); |
7 | | - $.ajax({ |
8 | | - type: "POST", |
9 | | - url: mw.util.wikiScript('api'), |
10 | | - data: {'action':'validatesignup', 'format':'json', 'field':fieldtype, 'inputVal':inputVal }, |
11 | | - dataType: 'json', |
12 | | - success: function( jsondata ){ |
13 | | - var image = "<img src='"+ imagePath + jsondata.signup.icon +"'>"; |
14 | | - var message = jsondata.signup.result; |
15 | | - valresult.innerHTML = image+message; |
16 | | - } |
17 | | - }); |
| 5 | + var inputVal = document.getElementById(fieldid).value; |
| 6 | + var valresult = document.getElementById(fieldid+'val'); |
| 7 | + $.ajax({ |
| 8 | + type: "POST", |
| 9 | + url: mw.util.wikiScript('api'), |
| 10 | + data: {'action':'validatesignup', 'format':'json', 'field':fieldtype, 'inputVal':inputVal }, |
| 11 | + dataType: 'json', |
| 12 | + success: function( jsondata ){ |
| 13 | + var image = "<img src='"+ imagePath + jsondata.signup.icon +"'>"; |
| 14 | + var message = jsondata.signup.result; |
| 15 | + valresult.innerHTML = image+message; |
| 16 | + } |
| 17 | + }); |
18 | 18 | } |
19 | 19 | |
20 | 20 | function passwordStrength() { |
| 21 | + var strength = document.getElementById('wpPassword2val'); |
| 22 | + var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g"); |
| 23 | + var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g"); |
| 24 | + var enoughRegex = new RegExp("(?=.{6,}).*", "g"); |
| 25 | + var pwd = document.getElementById("wpPassword2"); |
21 | 26 | |
22 | | - var strength = document.getElementById('wpPassword2val'); |
23 | | - var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g"); |
24 | | - var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g"); |
25 | | - var enoughRegex = new RegExp("(?=.{6,}).*", "g"); |
26 | | - var pwd = document.getElementById("wpPassword2"); |
27 | | - |
28 | | - if (pwd.value.length==0) { |
29 | | - strength.innerHTML = mw.message( 'signupapi-enterpassword' ); |
30 | | - } else if (pwd.value.length<minlength) { |
31 | | - strength.innerHTML = mw.message( 'signupapi-passwordtooshort', minlength ); |
32 | | - $("#progress").progressbar({value: 10}); |
33 | | - $("div.ui-progressbar-value").css("background","red"); |
34 | | - } else if (strongRegex.test(pwd.value)) { |
35 | | - strength.innerHTML = '<span style="color:green">'+mw.message( 'signupapi-strong' )+'</span>'; |
36 | | - $("#progress").progressbar({value: 100}); |
37 | | - $("div.ui-progressbar-value").css("background","green"); |
38 | | - } else if (mediumRegex.test(pwd.value)) { |
39 | | - strength.innerHTML = '<span style="color:orange">'+mw.message( 'signupapi-medium' )+'</span>'; |
40 | | - $("#progress").progressbar({value: 60}); |
41 | | - $("div.ui-progressbar-value").css("background","orange"); |
42 | | - } else { |
43 | | - strength.innerHTML = '<span style="color:red">'+mw.message( 'signupapi-weak' )+'</span>'; |
44 | | - $("#progress").progressbar({value: 30}); |
45 | | - $("div.ui-progressbar-value").css("background","red"); |
46 | | - } |
| 27 | + if (pwd.value.length==0) { |
| 28 | + strength.innerHTML = mw.message( 'signupapi-enterpassword' ); |
| 29 | + } else if (pwd.value.length<minlength) { |
| 30 | + strength.innerHTML = mw.message( 'signupapi-passwordtooshort', minlength ); |
| 31 | + $("#progress").progressbar({value: 10}); |
| 32 | + $("div.ui-progressbar-value").css("background","red"); |
| 33 | + } else if (strongRegex.test(pwd.value)) { |
| 34 | + strength.innerHTML = '<span style="color:green">'+mw.message( 'signupapi-strong' )+'</span>'; |
| 35 | + $("#progress").progressbar({value: 100}); |
| 36 | + $("div.ui-progressbar-value").css("background","green"); |
| 37 | + } else if (mediumRegex.test(pwd.value)) { |
| 38 | + strength.innerHTML = '<span style="color:orange">'+mw.message( 'signupapi-medium' )+'</span>'; |
| 39 | + $("#progress").progressbar({value: 60}); |
| 40 | + $("div.ui-progressbar-value").css("background","orange"); |
| 41 | + } else { |
| 42 | + strength.innerHTML = '<span style="color:red">'+mw.message( 'signupapi-weak' )+'</span>'; |
| 43 | + $("#progress").progressbar({value: 30}); |
| 44 | + $("div.ui-progressbar-value").css("background","red"); |
| 45 | + } |
47 | 46 | } |
48 | 47 | |
49 | | - |
50 | 48 | function checkRetype( pass,retype ) { |
51 | | - var valresult = document.getElementById('wpRetypeval'); |
52 | | - var image = ""; |
53 | | - var message = ""; |
54 | | - if ( pass==retype ) { |
55 | | - image = "<img src='"+ imagePath +"MW-Icon-CheckMark.png'>"; |
56 | | - message = mw.message( 'signupapi-passwordsmatch' ); |
57 | | - }else { |
58 | | - image = "<img src='"+ imagePath +"MW-Icon-NoMark.png'>"; |
59 | | - message = mw.message( 'signupapi-badretype' ); |
60 | | - } |
61 | | - valresult.innerHTML = image+message; |
| 49 | + var valresult = document.getElementById('wpRetypeval'); |
| 50 | + var image = ""; |
| 51 | + var message = ""; |
| 52 | + if ( pass==retype ) { |
| 53 | + image = "<img src='"+ imagePath +"MW-Icon-CheckMark.png'>"; |
| 54 | + message = mw.message( 'signupapi-passwordsmatch' ); |
| 55 | + }else { |
| 56 | + image = "<img src='"+ imagePath +"MW-Icon-NoMark.png'>"; |
| 57 | + message = mw.message( 'signupapi-badretype' ); |
| 58 | + } |
| 59 | + valresult.innerHTML = image+message; |
62 | 60 | } |
63 | 61 | |
64 | 62 | $('#wpName2').change(function() {validateInput("username","wpName2");}); |