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 1 commit
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
21 changes: 20 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,23 @@
var bgImg = 'url(' + randomImages[rndNum] + ')';
$("#login-page").css('background-image', bgImg );
});
$(document).ready(function() {
var buttonGroup = $("<span class='input-group-btn'><button type='button' class='btn btn-flat' title='${i18n('portal.admin.admin_login.showPassword')?html}'><span class='fa fa-eye'></span><span class='sr-only'>${i18n('portal.admin.admin_login.showPassword')?html}</span></button></span>");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use "message?js_string?html here" ? This way if we add the ' character it won't break ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems so, yes (for the occurence inside the title attibute)

Copy link
Member

@jonenst jonenst Jan 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not all -5- edit 6 occurences ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it cannot hurt to do it everywhere, I guess, but only this occurence is susceptible to break if a ' is unescaped.

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("${i18n('portal.admin.admin_login.hidePassword')?html}");
button.attr('title',"${i18n('portal.admin.admin_login.hidePassword')?html}")
} else {
$('#password').attr('type','password');
button.find('span:first-child').removeClass('fa-eye-slash').addClass('fa-eye');
button.find('span:last-child').text("${i18n('portal.admin.admin_login.showPassword')?html}");
button.attr('title',"${i18n('portal.admin.admin_login.showPassword')?html}")
}
$('#password').focus();
});
$('#password').after(buttonGroup);
});
</script>