Use submit event in login form

It's a pet peeve from me when logging into my personal Hydra that I
always have to press the button rather than hitting Return after entering
my password.

Reason for that is that the form doesn't have a "submit" button, so far
it was always listened to the "click" event. Submit does that and you
can hit Return alternatively.
This commit is contained in:
Maximilian Bosch 2024-03-07 18:44:13 +01:00 committed by Martin Weinelt
parent 969eb3eeac
commit ef6be80f54

View file

@ -33,7 +33,7 @@
<div id="hydra-signin" class="modal hide fade" tabindex="-1" role="dialog" aria-hidden="true"> <div id="hydra-signin" class="modal hide fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
<form> <form id="signin-form">
<div class="modal-body"> <div class="modal-body">
<div class="form-group"> <div class="form-group">
<label for="username" class="col-form-label">User name</label> <label for="username" class="col-form-label">User name</label>
@ -45,7 +45,7 @@
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button id="do-signin" type="button" class="btn btn-primary">Sign in</button> <button type="submit" class="btn btn-primary">Sign in</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button> <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div> </div>
</form> </form>
@ -57,10 +57,11 @@
function finishSignOut() { } function finishSignOut() { }
$("#do-signin").click(function() { $("#signin-form").submit(function(e) {
e.preventDefault();
requestJSON({ requestJSON({
url: "[% c.uri_for('/login') %]", url: "[% c.uri_for('/login') %]",
data: $(this).parents("form").serialize(), data: $(this).serialize(),
type: 'POST', type: 'POST',
success: function(data) { success: function(data) {
window.location.reload(); window.location.reload();