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

Fixed in password resetting email link. #5656

Merged
merged 1 commit into from Mar 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -11,7 +11,7 @@ public class PasswordResetInitResponse {
* null or not instead?
*/
private boolean emailFound;
private String resetUrl;
private String resetUrlPart;
private PasswordResetData passwordResetData;

public PasswordResetInitResponse(boolean emailFound) {
Expand All @@ -21,32 +21,15 @@ public PasswordResetInitResponse(boolean emailFound) {
public PasswordResetInitResponse(boolean emailFound, PasswordResetData passwordResetData) {
this.emailFound = emailFound;
this.passwordResetData = passwordResetData;
// default to localhost
String finalHostname = "localhost";
String configuredHostname = System.getProperty(SystemConfig.FQDN);
if (configuredHostname != null) {
if (configuredHostname.equals("localhost")) {
// must be a dev environment
finalHostname = "localhost:8181";
} else {
finalHostname = configuredHostname;
}
} else {
try {
finalHostname = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException ex) {
// just use the dev address
}
}
this.resetUrl = "https://" + finalHostname + "/passwordreset.xhtml?token=" + passwordResetData.getToken();
this.resetUrlPart = "/passwordreset.xhtml?token=" + passwordResetData.getToken();
}

public boolean isEmailFound() {
return emailFound;
}

public String getResetUrl() {
return resetUrl;
public String getResetUrl(String prefix) {
return prefix + resetUrlPart;
}

public PasswordResetData getPasswordResetData() {
Expand Down
Expand Up @@ -56,6 +56,9 @@ public class PasswordResetPage implements java.io.Serializable {
@EJB
PasswordValidatorServiceBean passwordValidatorService;

@EJB
SystemConfig systemConfig;

/**
* The unique string used to look up a user and continue the password reset
* process.
Expand Down Expand Up @@ -113,7 +116,7 @@ public String sendPasswordResetLink() {
PasswordResetData passwordResetData = passwordResetInitResponse.getPasswordResetData();
if (passwordResetData != null) {
BuiltinUser foundUser = passwordResetData.getBuiltinUser();
passwordResetUrl = passwordResetInitResponse.getResetUrl();
passwordResetUrl = passwordResetInitResponse.getResetUrl(systemConfig.getDataverseSiteUrl());
actionLogSvc.log( new ActionLogRecord(ActionLogRecord.ActionType.BuiltinUser, "passwordResetSent")
.setInfo("Email Address: " + emailAddress) );
} else {
Expand Down
Expand Up @@ -42,6 +42,9 @@ public class PasswordResetServiceBean {
@EJB
AuthenticationServiceBean authService;

@EJB
SystemConfig systemConfig;

@PersistenceContext(unitName = "VDCNet-ejbPU")
private EntityManager em;

Expand Down Expand Up @@ -81,7 +84,7 @@ public PasswordResetInitResponse requestPasswordReset( BuiltinUser aUser, boolea
em.persist(passwordResetData);
PasswordResetInitResponse passwordResetInitResponse = new PasswordResetInitResponse(true, passwordResetData);
if ( sendEmail ) {
sendPasswordResetEmail(aUser, passwordResetInitResponse.getResetUrl());
sendPasswordResetEmail(aUser, passwordResetInitResponse.getResetUrl(systemConfig.getDataverseSiteUrl()));
}

return passwordResetInitResponse;
Expand Down