Revision 49406
Added by Sofia Baltzi over 6 years ago
RemindUsernameServlet.java | ||
---|---|---|
1 | 1 |
package eu.dnetlib.openaire.usermanagement; |
2 | 2 |
|
3 | 3 |
import com.unboundid.ldap.sdk.LDAPException; |
4 |
import eu.dnetlib.openaire.user.utils.EmailSender; |
|
4 | 5 |
import eu.dnetlib.openaire.user.utils.LDAPActions; |
5 | 6 |
import org.apache.log4j.Logger; |
6 | 7 |
import org.springframework.beans.factory.annotation.Autowired; |
... | ... | |
29 | 30 |
@Autowired |
30 | 31 |
private LDAPActions ldapActions; |
31 | 32 |
|
32 |
//private EmailActions emailActions; |
|
33 |
@Autowired |
|
34 |
private EmailSender emailSender; |
|
33 | 35 |
|
34 | 36 |
private Logger logger = Logger.getLogger(RemindUsernameServlet.class); |
35 | 37 |
|
... | ... | |
44 | 46 |
|
45 | 47 |
try{ |
46 | 48 |
String username = ldapActions.getUsername(formEmail); |
47 |
if ( username != null && !username.isEmpty()) { |
|
48 |
//emailActions.sendUsernameReminder(formEmail); |
|
49 |
if (username != null && !username.isEmpty()) { |
|
49 | 50 |
|
51 |
String verificationCodeMsg = "Hello,\n" + |
|
52 |
"\n" + "A username reminder has been requested for your OpenAIRE account.\n" + |
|
53 |
" Your username is "+ username + ". Thank you. "; |
|
54 |
|
|
55 |
String verificationCodeSubject = "Your OpenAIRE username"; |
|
56 |
|
|
57 |
emailSender.sendEmail(formEmail, verificationCodeSubject, verificationCodeMsg); |
|
58 |
|
|
50 | 59 |
} else { |
51 | 60 |
request.getSession().setAttribute("message", "User not found"); |
52 | 61 |
response.sendRedirect("./remindUsername.jsp"); |
53 | 62 |
} |
54 | 63 |
|
55 |
|
|
56 | 64 |
} catch (LDAPException ldape) { |
57 | 65 |
//TODO create error page |
58 | 66 |
logger.error("Could not find user with email " + formEmail, ldape); |
Also available in: Unified diff
Fic errors! It works!