Don't rely on the password field's existence for admins (#534)

* Don't rely on the password field's existence for admins

We don't have the field when it's an admin user that's logged in. A
nicer language would have caught this unfortunately.
This commit is contained in:
gbrodman 2020-03-26 15:55:54 -04:00 committed by GitHub
parent 507aee7f30
commit b9d846cd42

View file

@ -121,7 +121,10 @@ registry.registrar.RegistryLock.prototype.showModal_ = function(targetElement, d
if (domain == null) { if (domain == null) {
goog.dom.getRequiredElement('domain-lock-input-value').focus(); goog.dom.getRequiredElement('domain-lock-input-value').focus();
} else { } else {
goog.dom.getRequiredElement('domain-lock-password').focus(); var passwordElem = goog.dom.getElement('domain-lock-password');
if (passwordElem != null) {
passwordElem.focus();
}
} }
// delete the modal when the user clicks the cancel button // delete the modal when the user clicks the cancel button
goog.events.listen( goog.events.listen(
@ -162,7 +165,8 @@ registry.registrar.RegistryLock.prototype.showModal_ = function(targetElement, d
*/ */
registry.registrar.RegistryLock.prototype.lockOrUnlockDomain_ = function(isLock, e) { registry.registrar.RegistryLock.prototype.lockOrUnlockDomain_ = function(isLock, e) {
var domain = goog.dom.getRequiredElement('domain-lock-input-value').value; var domain = goog.dom.getRequiredElement('domain-lock-input-value').value;
var password = goog.dom.getRequiredElement('domain-lock-password').value; var passwordElem = goog.dom.getElement('domain-lock-password');
var password = passwordElem == null ? null : passwordElem.value;
goog.net.XhrIo.send('/registry-lock-post', goog.net.XhrIo.send('/registry-lock-post',
e => this.fillLocksPage_(e), e => this.fillLocksPage_(e),
'POST', 'POST',