Skip to content

LUTECE-2189 : Add a button to display the password on the login page #138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ admin_login.passwordLabel=Password
admin_login.forgotPassword=Forgot password
admin_login.forgotLogin=Forgot access code
admin_login.buttonConnect=Connect
admin_login.showPassword=Display the password
admin_login.hidePassword=Hide the password

# Template admin_home
admin_home.connectedUser=Connected user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ admin_login.passwordLabel=Mot de passe
admin_login.forgotPassword=Mot de passe oubli\u00e9
admin_login.forgotLogin=Code d'acc\u00e8s oubli\u00e9
admin_login.buttonConnect=Se connecter
admin_login.showPassword=Afficher le mot de passe
admin_login.hidePassword=Masquer le mot de passe

# Template admin_home
admin_home.connectedUser=Utilisateur connect\u00e9
Expand Down
23 changes: 22 additions & 1 deletion webapp/WEB-INF/templates/admin/admin_login.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<label class="sr-only" for="password">#i18n{portal.admin.admin_login.passwordLabel}</label>
<div class="input-group">
<div class="input-group-addon"><span class="fa fa-lock"></span></div>
<input type="password" name="password" class="form-control" placeholder="#i18n{portal.admin.admin_login.passwordLabel}">
<input id="password" type="password" name="password" class="form-control" placeholder="#i18n{portal.admin.admin_login.passwordLabel}">
</div>
</div>
<button type="submit" class="btn btn-primary btn-block btn-flat">#i18n{portal.admin.admin_login.buttonConnect}</button>
Expand All @@ -49,4 +49,25 @@
var bgImg = 'url(' + randomImages[rndNum] + ')';
$("#login-page").css('background-image', bgImg );
});
$(document).ready(function() {
var showPasswordText = "${i18n('portal.admin.admin_login.showPassword')?html}";
var hidePasswordText = "${i18n('portal.admin.admin_login.hidePassword')?html}";
var buttonGroup = $("<span class='input-group-btn'><button type='button' class='btn btn-flat' title=\"" + showPasswordText + "\"><span class='fa fa-eye'></span><span class='sr-only'>" + showPasswordText + "</span></button></span>");
var button = buttonGroup.find('button')
.click(function() {
if ($('#password').attr('type') === 'password') {
$('#password').attr('type','text');
button.find('span:first-child').removeClass('fa-eye').addClass('fa-eye-slash');
button.find('span:last-child').text(hidePasswordText);
button.attr('title',hidePasswordText)
} else {
$('#password').attr('type','password');
button.find('span:first-child').removeClass('fa-eye-slash').addClass('fa-eye');
button.find('span:last-child').text(showPasswordText);
button.attr('title',showPasswordText)
}
$('#password').focus();
});
$('#password').after(buttonGroup);
});
</script>