neb*_*ula 5 liferay password-recovery liferay-6
我使用钩子定制了注册页面.
我想在注册页面中添加安全问题,当用户Liferay第一次登录时,会设置默认安全问题.
那么如何在首次登录时在注册页面中添加安全问题呢?
小智 1
首先,您必须自定义create_account.jsp页面,添加通常在 上找到的相同选择框和输入update_reminder_query.jsp:也就是说,您必须添加创建帐户时输入密码提醒的 UI。
之后,您必须为新用户保存这些值,并且您可能可以挂钩实现UserLocalService,添加代码来更新提醒查询。像这样的事情应该有效:
public class UserLocalServiceImpl extends UserLocalServiceWrapper {
public UserLocalServiceImpl(UserLocalService userLocalService) {
super(userLocalService);
}
@Override
public User addUser(
long creatorUserId, long companyId, boolean autoPassword,
String password1, String password2, boolean autoScreenName,
String screenName, String emailAddress, long facebookId,
String openId, Locale locale, String firstName, String middleName,
String lastName, int prefixId, int suffixId, boolean male,
int birthdayMonth, int birthdayDay, int birthdayYear,
String jobTitle, long[] groupIds, long[] organizationIds,
long[] roleIds, long[] userGroupIds, boolean sendEmail,
ServiceContext serviceContext)
throws PortalException, SystemException {
// User
User user = super.addUser(
creatorUserId, companyId, autoPassword, password1, password2,
autoScreenName, screenName, emailAddress, facebookId, openId,
locale, firstName, middleName, lastName, prefixId, suffixId, male,
birthdayMonth, birthdayDay, birthdayYear, jobTitle, groupIds,
organizationIds, roleIds, userGroupIds, sendEmail, serviceContext);
// Reminder query
String question = ParamUtil.getString(
serviceContext, "reminderQueryQuestion");
String answer = ParamUtil.getString(
serviceContext, "reminderQueryAnswer");
if (Validator.isNotNull(question) || Validator.isNotNull(answer)) {
if (question.equals(UsersAdminUtil.CUSTOM_QUESTION)) {
question = ParamUtil.getString(
serviceContext, "reminderQueryCustomQuestion");
}
updateReminderQuery(user.getUserId(), question, answer);
}
return user;
}
}
Run Code Online (Sandbox Code Playgroud)
您可以覆盖CreateAccountStruts 操作,但我认为在服务中执行此操作更安全,以便在出现错误时进行事务处理(例如,如果用户没有输入提醒查询的答案)...但是你应该检查一下才能确定!
另外,无论如何,您可能都必须自定义 Struts 操作,以便处理可能的UserReminderQueryException...
| 归档时间: |
|
| 查看次数: |
1713 次 |
| 最近记录: |