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

/admin/doSignup: Allow hiding the temporary password and adding a message to the email #132

Merged
merged 1 commit into from
Jun 11, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/main/java/org/jenkinsci/account/AdminUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,13 @@ public HttpResponse doDoSignup(
@QueryParameter String userid,
@QueryParameter String firstName,
@QueryParameter String lastName,
@QueryParameter String email
@QueryParameter String email,
@QueryParameter boolean skipPassword,
@QueryParameter String message
) throws NamingException, MessagingException {
String password = app.createRecord(userid, firstName, lastName, email);

app.new User(userid,email).mailPassword(password);
app.new User(userid,email).mailAccountCreated(!skipPassword, password, message);

return HttpResponses.plainText("Created");
}
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/org/jenkinsci/account/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,20 @@ public void mailPassword(String password) throws MessagingException {
"Please visit " + getUrl() + " and update your password and profile\n", "text/plain");
}

/**
* Sends a new password to this user.
*/
public void mailAccountCreated(boolean sendPassword, String password, @CheckForNull String message) throws MessagingException {
mail("Admin <admin@jenkins-ci.org>", mail, "New account on the Jenkins project infrastructure",
"Dear recipient, \n\n" +
"We have created a new Jenkins project account for you. Your new user ID is " + id + "\n" +
( sendPassword ? "Your temporary password is " + password + "\n" : "" ) +
( StringUtils.isNotBlank(message) ? message + "\n" : "" ) +
"\n" +
( sendPassword ? "Please visit " + getUrl() + " and update your password and profile\n" : "" ),
"text/plain");
}

/**
* Sends a new password and a password reset notification to this user.
*/
Expand Down