Skip to content

Commit

Permalink
Non empty database should not fail when finishing database setup -
Browse files Browse the repository at this point in the history
TRUNK-4968
  • Loading branch information
dkayiwa committed Nov 2, 2016
1 parent 253fd3a commit 78d8605
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import liquibase.changelog.ChangeSet;

import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand All @@ -51,6 +49,7 @@
import org.openmrs.api.APIAuthenticationException;
import org.openmrs.api.PasswordException;
import org.openmrs.api.context.Context;
import org.openmrs.api.context.ContextAuthenticationException;
import org.openmrs.module.MandatoryModuleException;
import org.openmrs.module.OpenmrsCoreModuleException;
import org.openmrs.module.web.WebModuleUtil;
Expand All @@ -75,6 +74,8 @@
import org.springframework.util.StringUtils;
import org.springframework.web.context.ContextLoader;

import liquibase.changelog.ChangeSet;

/**
* This is the first filter that is processed. It is only active when starting OpenMRS for the very
* first time. It will redirect all requests to the {@link WebConstants#SETUP_PAGE_URL} if the
Expand Down Expand Up @@ -1765,9 +1766,14 @@ && getRuntimePropertiesFile().setReadable(true)) {
try {
// change the admin user password from "test" to what they input above
if (wizardModel.createTables) {
Context.authenticate("admin", "test");
Context.getUserService().changePassword("test", wizardModel.adminUserPassword);
Context.logout();
try {
Context.authenticate("admin", "test");
Context.getUserService().changePassword("test", wizardModel.adminUserPassword);
Context.logout();
}
catch (ContextAuthenticationException ex) {
log.info("No need to change admin password.");
}
}
}
catch (Exception e) {
Expand Down

0 comments on commit 78d8605

Please sign in to comment.