-
-
Notifications
You must be signed in to change notification settings - Fork 956
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SAK-28184 new account tool should email users a link to activate thei…
…r accounts SAK-28184 adding README.md
- Loading branch information
Showing
17 changed files
with
866 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
reset-pass/account-validator-impl/src/bundle/validate_requestAccount.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0"?> | ||
<emailTemplates> | ||
<emailTemplate> | ||
<subject>Welcome To ${localSakaiName}!</subject> | ||
<message>Thank you for requesting an account for ${localSakaiName}, ${institution}'s learning management system. You're almost done! | ||
|
||
To create an account, click on the following link or paste it into your favourite web browser, and fill in the form. | ||
${url} | ||
|
||
If you haven't requested this account, you can safely ignore this message. | ||
</message> | ||
<locale></locale> | ||
</emailTemplate> | ||
</emailTemplates> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
...ool/src/java/org/sakaiproject/accountvalidator/tool/producers/RequestAccountProducer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
package org.sakaiproject.accountvalidator.tool.producers; | ||
|
||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
import org.sakaiproject.accountvalidator.model.ValidationAccount; | ||
import org.sakaiproject.entitybroker.EntityReference; | ||
import org.sakaiproject.user.api.User; | ||
import org.sakaiproject.user.api.UserNotDefinedException; | ||
import uk.org.ponder.messageutil.TargettedMessage; | ||
import uk.org.ponder.rsf.components.*; | ||
import uk.org.ponder.rsf.flow.ActionResultInterceptor; | ||
import uk.org.ponder.rsf.view.ComponentChecker; | ||
import uk.org.ponder.rsf.view.ViewComponentProducer; | ||
import uk.org.ponder.rsf.viewstate.ViewParameters; | ||
|
||
|
||
/** | ||
* Produces requestAccount.html - builds a form that allows the user to claim an account that has been created for them | ||
* @author bbailla2 | ||
*/ | ||
public class RequestAccountProducer extends BaseValidationProducer implements ViewComponentProducer, ActionResultInterceptor | ||
{ | ||
private static final Log log = LogFactory.getLog(RequestAccountProducer.class); | ||
public static final String VIEW_ID = "requestAccount"; | ||
|
||
public String getViewID() | ||
{ | ||
return VIEW_ID; | ||
} | ||
|
||
public void init() | ||
{ | ||
|
||
} | ||
|
||
public void fillComponents(UIContainer tofill, ViewParameters viewparams, ComponentChecker checker) | ||
{ | ||
Object[] args = new Object[]{serverConfigurationService.getString("ui.service", "Sakai")}; | ||
UIMessage.make(tofill, "welcome1", "validate.welcome1", args); | ||
UIMessage.make(tofill, "welcome2", "validate.welcome.request", args); | ||
|
||
ValidationAccount va = getValidationAccount(viewparams, tml); | ||
if (va == null) | ||
{ | ||
// handled by getValidationAccount | ||
return; | ||
} | ||
else if (!va.getAccountStatus().equals(ValidationAccount.ACCOUNT_STATUS_REQUEST_ACCOUNT)) | ||
{ | ||
// this form is not appropriate | ||
args = new Object[] {va.getValidationToken()}; | ||
// no such validation of the required account status | ||
tml.addMessage(new TargettedMessage("msg.noSuchValidation", args, TargettedMessage.SEVERITY_ERROR)); | ||
return; | ||
} | ||
else if (ValidationAccount.STATUS_CONFIRMED.equals(va.getStatus())) | ||
{ | ||
args = new Object[] {va.getValidationToken()}; | ||
tml.addMessage(new TargettedMessage("msg.alreadyValidated", args, TargettedMessage.SEVERITY_ERROR)); | ||
return ; | ||
} | ||
else if (sendLegacyLinksEnabled()) | ||
{ | ||
// Ignore; the request account feature should work independently of legacy links | ||
} | ||
|
||
User u = null; | ||
try | ||
{ | ||
u = userDirectoryService.getUser(EntityReference.getIdFromRef(va.getUserId())); | ||
} | ||
catch (UserNotDefinedException e) | ||
{ | ||
log.error("user ID does not exist for ValidationAccount with tokenId: " + va.getValidationToken()); | ||
tml.addMessage(new TargettedMessage("validate.userNotDefined", new Object[]{}, TargettedMessage.SEVERITY_ERROR)); | ||
} | ||
|
||
if (u != null) | ||
{ | ||
// we need some values to fill in. The nulls are placeholders. Other UIs use the same message with createdBy.getDisplayName() and createdBy.getEmailAddress(). | ||
args = new Object[]{ | ||
serverConfigurationService.getString("ui.service", "Sakai"), | ||
null, | ||
null, | ||
u.getDisplayId() | ||
}; | ||
|
||
UIForm detailsForm = UIForm.make(tofill, "setDetailsForm"); | ||
|
||
UICommand.make(detailsForm, "addDetailsSub", UIMessage.make("submit.new.account"), "accountValidationLocator.validateAccount"); | ||
|
||
String otp = "accountValidationLocator." + va.getId(); | ||
UIMessage.make(detailsForm, "username.new", "username.new", args); | ||
UIOutput.make(detailsForm, "eid", u.getDisplayId()); | ||
|
||
UIInput.make(detailsForm, "firstName", otp + ".firstName", u.getFirstName()); | ||
UIInput.make(detailsForm, "surName", otp + ".surname", u.getLastName()); | ||
|
||
boolean passwordPolicyEnabled = userDirectoryService.getPasswordPolicy() != null; | ||
String passwordPolicyEnabledJavaScript = "VALIDATOR.isPasswordPolicyEnabled = " + Boolean.toString(passwordPolicyEnabled) + ";"; | ||
UIVerbatim.make(tofill, "passwordPolicyEnabled", passwordPolicyEnabledJavaScript); | ||
|
||
UIBranchContainer row1 = UIBranchContainer.make(detailsForm, "passrow1:"); | ||
UIInput.make(row1, "password1", otp + ".password"); | ||
|
||
UIBranchContainer row2 = UIBranchContainer.make(detailsForm, "passrow2:"); | ||
UIInput.make(row2, "password2", otp + ".password2"); | ||
|
||
// If we have some terms, get the user to accept them. | ||
if (!"".equals(serverConfigurationService.getString("account-validator.terms"))) | ||
{ | ||
String termsURL = serverConfigurationService.getString("account-validator.terms"); | ||
UIBranchContainer termsRow = UIBranchContainer.make(detailsForm, "termsrow:"); | ||
|
||
UIBoundBoolean.make(termsRow, "terms", otp + ".terms"); | ||
// If someone wants to re-write this to be RSF like great, but this works. | ||
// Although it doesn't escape the bundle strings. | ||
String terms = messageLocator.getMessage("terms", new Object[] | ||
{ | ||
"<a href='" + termsURL + "' target='_new'>" + messageLocator.getMessage("terms.link")+"</a>" | ||
}); | ||
UIVerbatim.make(termsRow, "termsLabel", terms); | ||
} | ||
|
||
detailsForm.parameters.add(new UIELBinding(otp + ".userId", va.getUserId())); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.