Commit 3aaca2d2 authored by Clément OUDOT's avatar Clément OUDOT
Browse files

Captcha for login form (#217)

parent 643f4de2
......@@ -70,7 +70,7 @@ if (
}
# Display captcha if it's enabled
if ( $portal->{captcha_img} ) {
if ( $portal->{captcha_mail_enabled} ) {
$template->param(
CAPTCHA_IMG => $portal->{captcha_img},
CAPTCHA_CODE => $portal->{captcha_code},
......
......@@ -99,7 +99,8 @@ color:#000;
}
#logincontent form {
height:230px;
min-height:200px;
height:auto;
}
#mailcontent form {
......
......@@ -39,7 +39,7 @@ form input[name=user] {
padding-left: 25px;
}
form input[type=password] {
form input[type=password], form input[name=captcha_user_code] {
border: 1px solid #aaa;
padding: 5px;
width: 200px;
......
......@@ -7,10 +7,21 @@
<input name="password" type="password" tabindex="2" /><br/>
</p>
<TMPL_IF NAME=CAPTCHA_IMG>
<p>
<img src="<TMPL_VAR NAME=CAPTCHA_IMG>" />
</p>
<p>
<span class="text-label"><lang en="Captcha" fr="Captcha" /></span><br />
<input type="text" name="captcha_user_code" size="<TMPL_VAR NAME=CAPTCHA_SIZE>" tabindex="3" /><br />
<input type="hidden" name="captcha_code" value="<TMPL_VAR NAME=CAPTCHA_CODE>" />
</p>
</TMPL_IF>
<TMPL_IF NAME="CHECK_LOGINS">
<p>
<label for="checkLogins">
<input type="checkbox" id="checkLogins" name="checkLogins" <TMPL_IF NAME="ASK_LOGINS">checked</TMPL_IF>/>
<input type="checkbox" id="checkLogins" name="checkLogins" <TMPL_IF NAME="ASK_LOGINS">checked</TMPL_IF> tabindex="4" />
<lang en="Check my last logins" fr="Voir mes dernières connexions"/>
</label>
</p>
......@@ -18,10 +29,10 @@
<hr class="solid" />
<div class="panel-buttons">
<button type="reset" class="negative" tabindex="4">
<button type="reset" class="negative" tabindex="10">
<lang en="Cancel" fr="Annuler" />
</button>
<button type="submit" class="positive" tabindex="3">
<button type="submit" class="positive" tabindex="8">
<lang en="Connect" fr="Se connecter" />
</button>
</div>
......
......@@ -8,10 +8,20 @@
<td><input name="password" type="password" tabindex="2" /></td>
</tr>
<TMPL_IF NAME=CAPTCHA_IMG>
<tr><td></td><td>
<img src="<TMPL_VAR NAME=CAPTCHA_IMG>" />
</td></tr>
<tr><th><lang en="Captcha" fr="Captcha" /></th>
<td><input type="text" name="captcha_user_code" size="<TMPL_VAR NAME=CAPTCHA_SIZE>" tabindex="3" />
<input type="hidden" name="captcha_code" value="<TMPL_VAR NAME=CAPTCHA_CODE>" /></td>
</tr>
</TMPL_IF>
<TMPL_IF NAME="CHECK_LOGINS">
<tr><td colspan="2"><div class="buttons">
<label for="checkLogins">
<input type="checkbox" id="checkLogins" name="checkLogins" <TMPL_IF NAME="ASK_LOGINS">checked</TMPL_IF>/>
<input type="checkbox" id="checkLogins" name="checkLogins" <TMPL_IF NAME="ASK_LOGINS">checked</TMPL_IF> tabindex="4" />
<lang en="Check my last logins" fr="Voir mes dernières connexions"/>
</label>
</div></td></tr>
......@@ -19,11 +29,11 @@
<tr><td colspan="2">
<div class="buttons">
<button type="reset" class="negative" tabindex="4">
<button type="reset" class="negative" tabindex="10">
<img src="<TMPL_VAR NAME="SKIN_PATH">/common/cancel.png" alt="" />
<lang en="Cancel" fr="Annuler" />
</button>
<button type="submit" class="positive" tabindex="3">
<button type="submit" class="positive" tabindex="8">
<img src="<TMPL_VAR NAME="SKIN_PATH">/common/accept.png" alt="" />
<lang en="Connect" fr="Se connecter" />
</button>
......
......@@ -205,7 +205,7 @@ sub display {
);
# Display captcha if it's enabled
if ( $self->{captcha_img} ) {
if ( $self->{captcha_login_enabled} ) {
%templateParams = (
%templateParams,
CAPTCHA_IMG => $self->{captcha_img},
......
......@@ -647,12 +647,11 @@ sub setDefaultValues {
$self->{mailOnPasswordChange} ||= 0;
# Captcha parameters
$self->{captcha_login_enabled} = 0 unless defined $self->{captcha_login_enabled};
$self->{captcha_mail_enabled} = 0 unless defined $self->{captcha_mail_enabled};
$self->{captcha_size} = 6 unless defined $self->{captcha_size};
$self->{captcha_output} ||=
'/usr/local/lemonldap-ng/htdocs/portal/captcha_output/';
$self->{captcha_data} ||= '/usr/local/lemonldap-ng/data/captcha/data/';
$self->{captcha_login_enabled} = 0
unless defined $self->{captcha_login_enabled};
$self->{captcha_mail_enabled} = 0
unless defined $self->{captcha_mail_enabled};
$self->{captcha_size} = 6 unless defined $self->{captcha_size};
# Notification
$self->{notificationWildcard} ||= "allusers";
......@@ -913,6 +912,7 @@ sub error_type {
PE_NOTIFICATION, PE_BADURL,
PE_CONFIRM, PE_MAILFORMEMPTY,
PE_MAILCONFIRMATION_ALREADY_SENT, PE_PASSWORDFORMEMPTY,
PE_CAPTCHAEMPTY,
)
)
);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment