Revision 49376
Added by Sofia Baltzi about 7 years ago
modules/uoa-user-management/trunk/src/main/java/eu/dnetlib/openaire/user/utils/VerificationActions.java | ||
---|---|---|
31 | 31 |
|
32 | 32 |
try { |
33 | 33 |
UserVerification userVerification = new UserVerification(username); |
34 |
logger.info("verificationCode: " + verificationCode); |
|
34 | 35 |
userVerification.setVerificationCode(verificationCode); |
35 | 36 |
userVerification.setDate(date); |
36 | 37 |
|
... | ... | |
57 | 58 |
UserVerification userVerificationOld = userVerificationDAO.fetchByUsername(username); |
58 | 59 |
|
59 | 60 |
UserVerification userVerification = new UserVerification(username); |
61 |
logger.info("1 . verificationCode: " + verificationCode); |
|
60 | 62 |
userVerification.setVerificationCode(verificationCode); |
63 |
logger.info("2 . verificationCode: " + verificationCode); |
|
61 | 64 |
userVerification.setDate(date); |
62 | 65 |
userVerification.setId(userVerificationOld.getId()); |
63 | 66 |
|
64 | 67 |
userVerificationDAO.update(userVerification); |
65 | 68 |
|
69 |
logger.info("3 . verificationCode: " + verificationCode); |
|
66 | 70 |
logger.info("Update user: " + username + " with verification code " + verificationCode); |
67 | 71 |
|
68 | 72 |
} catch (SQLException e) { |
... | ... | |
103 | 107 |
* Checks if the verification row exists for the given username |
104 | 108 |
*/ |
105 | 109 |
public boolean verificationEntryExists(String username, String verificationCode) { |
106 |
//TODO |
|
107 |
//return false; |
|
108 |
throw new UnsupportedOperationException(); |
|
110 |
|
|
111 |
try { |
|
112 |
UserVerification userVerification = userVerificationDAO.fetchByUsername(username); |
|
113 |
|
|
114 |
if (userVerification == null) { |
|
115 |
logger.info("There is no user with username: " + username); |
|
116 |
return false; |
|
117 |
} |
|
118 |
else { |
|
119 |
logger.info("User: " + username + " was found!"); |
|
120 |
|
|
121 |
if (userVerification.getVerificationCode() == verificationCode) { |
|
122 |
logger.info("... and verification code: " + verificationCode + " is correct!"); |
|
123 |
} |
|
124 |
return true; |
|
125 |
} |
|
126 |
} catch (SQLException e) { |
|
127 |
e.printStackTrace(); |
|
128 |
logger.info("Fail to search user.", e); |
|
129 |
} |
|
130 |
|
|
131 |
return true; |
|
109 | 132 |
} |
110 | 133 |
|
111 | 134 |
public DataSourceConnector getDataSourceConnector() { |
modules/uoa-user-management/trunk/src/main/java/eu/dnetlib/openaire/user/dao/UserVerificationDAO.java | ||
---|---|---|
59 | 59 |
public UserVerification fetchByUsername(final String username) |
60 | 60 |
throws SQLException |
61 | 61 |
{ |
62 |
logger.info("Datasource -> " + dataSourceConnector.getDatasource()); |
|
62 |
//logger.info("Datasource -> " + dataSourceConnector.getDatasource());
|
|
63 | 63 |
List<UserVerification> userVerifications = executeQuery(FETCH_BY_USERNAME, new Statement.Initializer() { |
64 | 64 |
@Override |
65 | 65 |
public void prepare(PreparedStatement stmt) throws SQLException { |
modules/uoa-user-management/trunk/src/main/resources/eu/dnetlib/openaire/user/springContext-userManagementService.xml | ||
---|---|---|
49 | 49 |
<property name="ldapConnector" ref="ldapConnector"/> |
50 | 50 |
</bean> |
51 | 51 |
|
52 |
<bean id="emailSender" class="eu.dnetlib.openaire.user.utils.EmailSender" > |
|
53 |
<property name="username" value="${mail.users.username}"/> |
|
54 |
<property name="password" value="${mail.users.password}"/> |
|
55 |
<property name="host" value="${mail.smtp.host}" /> |
|
56 |
<property name="port" value="${mail.smtp.port}" /> |
|
57 |
<property name="from" value="${mail.smtp.from}" /> |
|
58 |
</bean> |
|
59 |
|
|
52 | 60 |
<!--<bean id="verificationActions" class="eu.dnetlib.openaire.user.utils.VerificationActions">--> |
53 | 61 |
<!--<property name="dataSourceConnector" ref="dataSourceConnector"/>--> |
54 | 62 |
<!--</bean>--> |
modules/uoa-user-management/trunk/src/main/resources/eu/dnetlib/openaire/user/springContext-userManagementService.properties | ||
---|---|---|
18 | 18 |
services.userman.ldap.usersDN = ou=users,dc=openaire,dc=eu |
19 | 19 |
services.userman.ldap.password = serenata |
20 | 20 |
services.userman.ldap.port = 389 |
21 |
|
|
22 |
#email sender properties |
|
23 |
mail.smtp.host = smtp.gmail.com |
|
24 |
mail.smtp.port = 587 |
|
25 |
mail.users.username = openaire.test@gmail.com |
|
26 |
mail.users.password = P@ssw0rD |
|
27 |
mail.smtp.from = openaire.test@gmail.com |
|
28 |
|
modules/uoa-user-management/trunk/pom.xml | ||
---|---|---|
133 | 133 |
<artifactId>commons-validator</artifactId> |
134 | 134 |
<version>1.6</version> |
135 | 135 |
</dependency> |
136 |
<dependency> |
|
137 |
<groupId>javax.mail</groupId> |
|
138 |
<artifactId>mail</artifactId> |
|
139 |
<version>1.4</version> |
|
140 |
</dependency> |
|
136 | 141 |
</dependencies> |
137 | 142 |
</project> |
Also available in: Unified diff
Fix mailSender