Added an icon to each login input of a closed eye when input type is set to password.
If you click the icon it switches to an open eye and the input type is set to text.
It's a pretty standard way to allow people to view their password before submitting it.
Signed-off-by: Scott <scottangel@mobiusconsortium.org>
Signed-off-by: Stephanie Leary <stephanie.leary@equinoxoli.org>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
handleSubmit() {
+ this.passwordVisible = false;
+
// post-login URL
let url: string = this.routeTo || '/staff/splash';
input.type == 'password' ? [input.type = 'text', icon.setAttribute('class','fas fa-eye')] : [input.type = 'password', icon.setAttribute('class', 'fas fa-eye-slash')];
input.focus();
});
+ let loginForm = document.getElementById('login_form');
+ loginForm.addEventListener('submit', ()=>{
+ input.type = 'password';
+ });
});
</script>
<div class='container'>
<hr>
<h3 class="text-center">[% l('Log in to Your Account') %]</h3>
- <form method='post'>
+ <form id="login_form" method='post'>
<div class="row text-center">[%# INCLUDE "opac/parts/login/help.tt2" %]</div>
[% IF ctx.login_failed_event %]
<div id='login-failed-message'>
</div>
<div class="col-sm w-50">
<div class="input-group">
- <input class="form-control" id="password_field" name="password" type="password" spellcheck="false"/>
+ <input class="form-control" id="password_field" name="password" type="password" spellcheck="false" autocomplete="false"/>
<span id="show_password" class="input-group-text pointer"><i class="fas fa-eye-slash"></i></span>
</div>
</div>
<div class="modal fade" id="loginModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
- <form method='post' action="/eg/opac/login?redirect_to=%2Feg%2Fopac%2Fmyopac%2Fmain">
+ <form id="login_form" method='post' action="/eg/opac/login?redirect_to=%2Feg%2Fopac%2Fmyopac%2Fmain">
<div class="modal-header">
<h1 class="modal-title" id="exampleModalLabel">[% l('Login To Evergreen') %]</h1>
<button type="button" class="close" data-dismiss="modal" aria-label=[% l("Close") %]>
</div>
<div class="col-sm w-50">
<div class="input-group">
- <input class="form-control" id="password_field" name="password" type="password" spellcheck="false"/>
+ <input class="form-control" id="password_field" name="password" type="password" spellcheck="false" autocomplete="false"/>
<span id="show_password" class="input-group-text pointer"><i class="fas fa-eye-slash"></i></span>
</div>
</div>
.pointer {
cursor: pointer;
}
+#password_visibility{
+ display: none;
+}
<!-- Password Visibility Checkbox -->
<script>
+ // Show the checkbox if JS is enabled
+ document.getElementById('password_visibility').style.display = 'block';
let checkbox = document.getElementById('password_visibility_checkbox');
let input = document.getElementById('password_field');
checkbox.addEventListener('change', () => {
else input.type = 'password';
input.focus();
});
+ // If the form is submitted revert the password field to a password input
+ let form = document.getElementById('opac-login-form');
+ form.addEventListener('submit', () => {
+ input.type = 'password';
+ });
</script>
[%- IF ctx.use_stripe %]
[% END %]
[% IF !sso_enabled || sso_native %]
[% l('Please enter the following information:') %]
- <form method='post'>
+ <form id="opac-login-form" method='post'>
<div class='login-form-left'>
<label for='username_field' class="lbl1" >[% l('Library Card Number or Username') %]</label>
<div class="input_bg">
<div class="input_bg">
<input id="password_field" name="password" type="password" spellcheck="false"/>
</div>
- <div class="input_bg">
+ <div id="password_visibility" class="input_bg">
<input id="password_visibility_checkbox" type="checkbox" />
<label for="password_visibility_checkbox">Show Password</label>
</div>
The input IDs are there to match the labels.
They are not referenced in the Login controller.
-->
- <form ng-submit="login(args)" name="login-form" class="form-horizontal" role="form">
+ <form ng-submit="login(args)" id="login_form" name="login-form" class="form-horizontal" role="form">
<div class="form-group">
<label class="col-md-4 control-label" for="login-username">[% l('Username') %]</label>
<div class="col-md-8">
<div class="col-md-8">
<div class="input-group">
<input type="password" id="login-password" class="form-control"
- placeholder="Password" spellcheck="false" ng-model="args.password"/>
+ placeholder="Password" spellcheck="false" autocomplete="false" ng-model="args.password"/>
<span id="show_password" class="input-group-addon pointer"><i class="glyphicon glyphicon-eye-close"></i></span>
</div>
</div>
input.type == 'password' ? [input.type = 'text', icon.setAttribute('class', 'glyphicon glyphicon-eye-open')] : [input.type = 'password', icon.setAttribute('class', 'glyphicon glyphicon-eye-close')];
input.focus();
});
+ $('#login_form').submit(()=>{
+ input.type='password';
+ });
</script>
\ No newline at end of file