Make the fresh login dialog autofocus the input and make it handle the enter key properly.
This commit is contained in:
parent
987177fd7e
commit
f746eb3381
1 changed files with 35 additions and 23 deletions
|
@ -816,18 +816,9 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading
|
||||||
|
|
||||||
// If the error is a fresh login required, show the dialog.
|
// If the error is a fresh login required, show the dialog.
|
||||||
if (resp.status == 401 && resp.data['error_type'] == 'fresh_login_required') {
|
if (resp.status == 401 && resp.data['error_type'] == 'fresh_login_required') {
|
||||||
bootbox.dialog({
|
var verifyNow = function() {
|
||||||
"message": 'It has been more than a few minutes since you last logged in, ' +
|
if (!$('#freshPassword').val()) { return; }
|
||||||
'so please verify your password to perform this sensitive operation:' +
|
|
||||||
'<form style="margin-top: 10px" action="javascript:void(0)">' +
|
|
||||||
'<input id="freshPassword" class="form-control" type="password" placeholder="Current Password">' +
|
|
||||||
'</form>',
|
|
||||||
"title": 'Please Verify',
|
|
||||||
"buttons": {
|
|
||||||
"verify": {
|
|
||||||
"label": "Verify",
|
|
||||||
"className": "btn-success",
|
|
||||||
"callback": function() {
|
|
||||||
var info = {
|
var info = {
|
||||||
'password': $('#freshPassword').val()
|
'password': $('#freshPassword').val()
|
||||||
};
|
};
|
||||||
|
@ -847,18 +838,39 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading
|
||||||
// Reject with the sign in error.
|
// Reject with the sign in error.
|
||||||
deferred.reject({'data': {'message': 'Invalid verification credentials'}});
|
deferred.reject({'data': {'message': 'Invalid verification credentials'}});
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
|
var box = bootbox.dialog({
|
||||||
|
"message": 'It has been more than a few minutes since you last logged in, ' +
|
||||||
|
'so please verify your password to perform this sensitive operation:' +
|
||||||
|
'<form style="margin-top: 10px" action="javascript:void(0)">' +
|
||||||
|
'<input id="freshPassword" class="form-control" type="password" placeholder="Current Password">' +
|
||||||
|
'</form>',
|
||||||
|
"title": 'Please Verify',
|
||||||
|
"buttons": {
|
||||||
|
"verify": {
|
||||||
|
"label": "Verify",
|
||||||
|
"className": "btn-success",
|
||||||
|
"callback": verifyNow
|
||||||
},
|
},
|
||||||
"close": {
|
"close": {
|
||||||
"label": "Cancel",
|
"label": "Cancel",
|
||||||
"className": "btn-default",
|
"className": "btn-default",
|
||||||
"callback": function() {
|
"callback": function() {
|
||||||
deferred.reject(resp);
|
deferred.reject({'data': {'message': 'Verification canceled'}});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
box.bind('shown.bs.modal', function(){
|
||||||
|
box.find("input").focus();
|
||||||
|
box.find("form").submit(function() {
|
||||||
|
box.modal('hide');
|
||||||
|
verifyNow();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Return a new promise. We'll accept or reject it based on the result
|
// Return a new promise. We'll accept or reject it based on the result
|
||||||
// of the login.
|
// of the login.
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
|
|
Reference in a new issue