Allow users the option of seeing their registry lock password (#663)

* Allow users the option of seeing their registry lock password

Only when entering it for the first time, of course.
This commit is contained in:
gbrodman 2020-07-05 20:08:22 -04:00 committed by GitHub
parent 683af3fa6e
commit 57d1d1697a
7 changed files with 47 additions and 3 deletions

View file

@ -106,6 +106,7 @@ registry.registrar.ContactSettings.prototype.renderItem = function(rspObj) {
registryLockAllowedForRegistrar: rspObj.registryLockAllowed registryLockAllowedForRegistrar: rspObj.registryLockAllowed
}); });
this.setupAppbar(); this.setupAppbar();
this.setupPasswordElemIfNecessary_(targetContactNdx);
} else { } else {
var contactsByType = {}; var contactsByType = {};
for (var c in contacts) { for (var c in contacts) {
@ -251,3 +252,26 @@ registry.registrar.ContactSettings.prototype.handleDeleteResponse =
} }
return rsp; return rsp;
}; };
// Show or hide the password based on what the user chooses
registry.registrar.ContactSettings.prototype.setupPasswordElemIfNecessary_ =
function(contactIndex) {
var showOrHidePasswordButton = goog.dom.getElement('showOrHideRegistryLockPassword')
var showOrHidePassword = function() {
var inputElement = goog.dom.getRequiredElement(
'contacts[' + contactIndex + '].registryLockPassword')
var type = inputElement.getAttribute('type')
if (type === 'password') {
showOrHidePasswordButton.text = 'Hide password';
inputElement.setAttribute('type', 'text');
} else {
showOrHidePasswordButton.text = 'Show password';
inputElement.setAttribute('type', 'password');
}
};
if (showOrHidePasswordButton != null) {
goog.events.listen(showOrHidePasswordButton,
goog.events.EventType.CLICK, showOrHidePassword, false, this);
}
};

View file

@ -260,6 +260,15 @@
{param isPassword: true /} {param isPassword: true /}
{param placeholder: $placeholder /} {param placeholder: $placeholder /}
{/call} {/call}
{if $item['allowedToSetRegistryLockPassword']}
<tr>
<td></td>
<td>
<a id="showOrHideRegistryLockPassword">Show password</a>
</td>
</tr>
{/if}
{/if} {/if}
<input type="hidden" name="{$namePrefix}allowedToSetRegistryLockPassword" <input type="hidden" name="{$namePrefix}allowedToSetRegistryLockPassword"
{if isNonnull($item['allowedToSetRegistryLockPassword'])} {if isNonnull($item['allowedToSetRegistryLockPassword'])}

View file

@ -167,13 +167,24 @@ public class RegistrarConsoleScreenshotTest extends WebDriverTestCase {
Thread.sleep(1000); Thread.sleep(1000);
driver.waitForElement(By.tagName("h1")); driver.waitForElement(By.tagName("h1"));
driver.waitForElement(By.id("reg-app-btn-edit")).click(); driver.waitForElement(By.id("reg-app-btn-edit")).click();
driver.diffPage("page"); // The password should show as dots when the user types it in
driver.findElement(By.id("contacts[1].registryLockPassword")).sendKeys("password");
driver.diffPage("page_with_password");
// Show the password if the user clicks the button
driver.findElement(By.id("showOrHideRegistryLockPassword")).click();
Thread.sleep(5);
driver.diffPage("page_with_shown_password");
// Hide it again
driver.findElement(By.id("showOrHideRegistryLockPassword")).click();
Thread.sleep(5);
driver.diffPage("page_with_password_after_hide");
// now actually set the password // now actually set the password
driver.findElement(By.id("contacts[1].registryLockPassword")).sendKeys("password");
driver.waitForElement(By.id("reg-app-btn-save")).click(); driver.waitForElement(By.id("reg-app-btn-save")).click();
Thread.sleep(500); Thread.sleep(500);
driver.diffPage("contactview"); driver.diffPage("contact_view");
server.runInAppEngineEnvironment( server.runInAppEngineEnvironment(
() -> { () -> {