Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LPS-107347 Portal does not request new password for the admin if database changed by Setup Wizard #113313

Closed
2 changes: 2 additions & 0 deletions build-test.xml
Expand Up @@ -8744,6 +8744,8 @@ browser.launcher.url=

setup.wizard.enabled=false

passwords.default.policy.changeable=false

mail.send.blacklist=

mail.session.jndi.name=
Expand Down
Expand Up @@ -318,7 +318,8 @@ public User addDefaultAdminUser(
updateLastLogin(
defaultAdminUser.getUserId(), defaultAdminUser.getLoginIP());

updatePasswordReset(defaultAdminUser.getUserId(), false);
updatePasswordReset(
defaultAdminUser.getUserId(), _isPasswordReset(companyId));

return defaultAdminUser;
}
Expand Down Expand Up @@ -1234,18 +1235,7 @@ public User addUserWithWorkflow(
}

user.setPasswordEncrypted(true);

PasswordPolicy passwordPolicy = defaultUser.getPasswordPolicy();

if ((passwordPolicy != null) && passwordPolicy.isChangeable() &&
passwordPolicy.isChangeRequired()) {

user.setPasswordReset(true);
}
else {
user.setPasswordReset(false);
}

user.setPasswordReset(_isPasswordReset(companyId));
user.setScreenName(screenName);
user.setEmailAddress(emailAddress);

Expand Down Expand Up @@ -4795,18 +4785,7 @@ public User updateIncompleteUser(
}

user.setPasswordEncrypted(true);

PasswordPolicy passwordPolicy = defaultUser.getPasswordPolicy();

if ((passwordPolicy != null) && passwordPolicy.isChangeable() &&
passwordPolicy.isChangeRequired()) {

user.setPasswordReset(true);
}
else {
user.setPasswordReset(false);
}

user.setPasswordReset(_isPasswordReset(companyId));
user.setScreenName(screenName);
user.setLanguageId(locale.toString());
user.setTimeZoneId(defaultUser.getTimeZoneId());
Expand Down Expand Up @@ -7520,6 +7499,26 @@ private void _invalidateTicket(User user) throws PortalException {
}
}

private boolean _isPasswordReset(long companyId) {
try {
PasswordPolicy passwordPolicy =
_passwordPolicyLocalService.getDefaultPasswordPolicy(companyId);

if ((passwordPolicy != null) && passwordPolicy.isChangeable() &&
passwordPolicy.isChangeRequired()) {

return true;
}
}
catch (PortalException portalException) {
if (_log.isWarnEnabled()) {
_log.warn(portalException, portalException);
}
}

return false;
}

private boolean _isPasswordUnchanged(
User user, String newPlaintextPwd, String newEncPwd)
throws PwdEncryptorException {
Expand Down
19 changes: 14 additions & 5 deletions portal-impl/src/com/liferay/portal/setup/SetupWizardUtil.java
Expand Up @@ -354,12 +354,21 @@ private static void _updateAdminUser(

boolean passwordReset = false;

PasswordPolicy passwordPolicy =
PasswordPolicyLocalServiceUtil.getDefaultPasswordPolicy(
company.getCompanyId());
try {
PasswordPolicy passwordPolicy =
PasswordPolicyLocalServiceUtil.getDefaultPasswordPolicy(
company.getCompanyId());

if ((passwordPolicy != null) && passwordPolicy.isChangeable() &&
passwordPolicy.isChangeRequired()) {

if ((passwordPolicy != null) && passwordPolicy.isChangeable()) {
passwordReset = true;
passwordReset = true;
}
}
catch (PortalException portalException) {
if (_log.isWarnEnabled()) {
_log.warn(portalException, portalException);
}
}

User user = SetupWizardSampleDataUtil.updateAdminUser(
Expand Down
Expand Up @@ -6,6 +6,48 @@ definition {
property test.prepare.bundle.properties = "false";
property testray.main.component.name = "Setup Wizard";

@description = "This is a use case for LPS-107347. It asserts that an admin is still required to change password with Setup Wizard disabled."
@priority = "4"
test AdminIsRequiredToChangePasswordWithSetupWizardDisabled {
property custom.properties = "passwords.default.policy.changeable=true${line.separator}setup.wizard.enabled=false";
property database.types = "mysql";
property testray.main.component.name = "Users and Organizations";

task ("When an admin logs in with Setup Wizard disabled") {
Navigator.openURL();

User._clickSignInLink();

Type.typePause(
locator1 = "TextInput#EMAIL_ADDRESS",
value1 = "test@liferay.com");

Type.typePause(
locator1 = "TextInput#PASSWORD",
value1 = "test");

User._clickSignInButton();

SignIn.agreeToTermsOfUse();
}

task ("Then the admin is still required to reset its password") {
Type(
locator1 = "TextInput#PASSWORD_1",
value1 = "test2");

Type(
locator1 = "TextInput#PASSWORD_2",
value1 = "test2");

Button.clickSubmitButton();

SignIn.setPasswordReminder();

AssertElementPresent(locator1 = "UserBar#USER_AVATAR_IMAGE");
}
}

@priority = "4"
test BasicConfigurationVisualLook {
property database.types = "mysql";
Expand Down