Revision 51695
Added by Sofia Baltzi almost 6 years ago
RegisterServlet.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.openaire.usermanagement; |
2 | 2 |
|
3 | 3 |
import eu.dnetlib.openaire.user.utils.EmailSender; |
4 |
import org.apache.commons.validator.routines.EmailValidator; |
|
4 | 5 |
import eu.dnetlib.openaire.user.utils.LDAPActions; |
5 | 6 |
import eu.dnetlib.openaire.user.utils.VerificationActions; |
6 | 7 |
import eu.dnetlib.openaire.usermanagement.utils.UrlConstructor; |
... | ... | |
64 | 65 |
try { |
65 | 66 |
|
66 | 67 |
if (username.matches("^[a-zA-Z0-9\\.\\_\\-]{4,150}") && !ldapActions.usernameExists(username) && !ldapActions.emailExists(email) |
67 |
&& !ldapActions.isZombieUsersEmail(email) && !ldapActions.isZombieUsersUsername(username)) { |
|
68 |
&& !ldapActions.isZombieUsersEmail(email) && !ldapActions.isZombieUsersUsername(username) && EmailValidator.getInstance().isValid(email)) {
|
|
68 | 69 |
|
69 | 70 |
ldapActions.createZombieUser(username, email, firstName, lastName, organization, password); |
70 | 71 |
logger.info("Zombie user successfully created"); |
... | ... | |
115 | 116 |
} |
116 | 117 |
|
117 | 118 |
if (!username.matches("^[a-zA-Z0-9\\.\\_\\-]")) { |
118 |
request.getSession().setAttribute("username_allowed_message", "You can use only letters, numbers, underscores, hyphens and periods.");
|
|
119 |
request.getSession().setAttribute("username_allowed_chars_message", "You can use letters, numbers, underscores, hyphens and periods.");
|
|
119 | 120 |
logger.info("Only letters, numbers, underscores, hyphens and periods."); |
120 | 121 |
} |
122 |
|
|
123 |
if (!username.matches("^[a-zA-Z0-9].*")) { |
|
124 |
request.getSession().setAttribute("username_first_char_message", "The username must start with letter or digit."); |
|
125 |
logger.info("The username must start with letter or digit."); |
|
126 |
} |
|
127 |
|
|
121 | 128 |
} |
122 | 129 |
|
123 | 130 |
if (ldapActions.usernameExists(username) || ldapActions.isZombieUsersUsername(username)) { |
... | ... | |
130 | 137 |
logger.info("There is another user with this email"); |
131 | 138 |
} |
132 | 139 |
|
140 |
if (!EmailValidator.getInstance().isValid(email)) { |
|
141 |
request.getSession().setAttribute("email_message", "Please enter a valid email."); |
|
142 |
logger.info("Invalid email."); |
|
143 |
} |
|
144 |
|
|
133 | 145 |
if (ldapActions.isZombieUsersEmail(email)) { |
134 | 146 |
request.getSession().setAttribute("email_message", "You have already registered with this email address! Please check your email to activate your account or contact OpenAIRE <a href=\"https://www.openaire.eu/support/helpdesk\">helpdesk</a>."); |
135 | 147 |
logger.info("There is another user with this email"); |
Also available in: Unified diff
Change username regulars expression - Allow usernames that start with character or digit, Change error messages