|
@ -88,6 +88,11 @@ public class SysService {
|
88
|
88
|
private String mailRetrievePasswordReplaceKey;
|
89
|
89
|
private String mailRetrievePasswordSubject;
|
90
|
90
|
private long timeLimitWithMailRetrivePassword = 10 * 60 * 1000;
|
|
91
|
|
|
92
|
private String orgMailRetrievePasswordContentTemplate;
|
|
93
|
private String orgMailRetrievePasswordReplaceKey;
|
|
94
|
private String orgMailRetrievePasswordSubject;
|
|
95
|
private long timeLimitWithOrgMailRetrivePassword = 10 * 60 * 1000;
|
91
|
96
|
|
92
|
97
|
private String regMobilePhoneReplaceKey;
|
93
|
98
|
private String regMobilePhoneContentTemplate;
|
|
@ -197,6 +202,38 @@ public class SysService {
|
197
|
202
|
this.timeLimitWithMailRetrivePassword = timeLimitWithMailRetrivePassword;
|
198
|
203
|
}
|
199
|
204
|
|
|
205
|
public String getOrgMailRetrievePasswordContentTemplate() {
|
|
206
|
return orgMailRetrievePasswordContentTemplate;
|
|
207
|
}
|
|
208
|
|
|
209
|
public void setOrgMailRetrievePasswordContentTemplate(String orgMailRetrievePasswordContentTemplate) {
|
|
210
|
this.orgMailRetrievePasswordContentTemplate = orgMailRetrievePasswordContentTemplate;
|
|
211
|
}
|
|
212
|
|
|
213
|
public String getOrgMailRetrievePasswordReplaceKey() {
|
|
214
|
return orgMailRetrievePasswordReplaceKey;
|
|
215
|
}
|
|
216
|
|
|
217
|
public void setOrgMailRetrievePasswordReplaceKey(String orgMailRetrievePasswordReplaceKey) {
|
|
218
|
this.orgMailRetrievePasswordReplaceKey = orgMailRetrievePasswordReplaceKey;
|
|
219
|
}
|
|
220
|
|
|
221
|
public String getOrgMailRetrievePasswordSubject() {
|
|
222
|
return orgMailRetrievePasswordSubject;
|
|
223
|
}
|
|
224
|
|
|
225
|
public void setOrgMailRetrievePasswordSubject(String orgMailRetrievePasswordSubject) {
|
|
226
|
this.orgMailRetrievePasswordSubject = orgMailRetrievePasswordSubject;
|
|
227
|
}
|
|
228
|
|
|
229
|
public long getTimeLimitWithOrgMailRetrivePassword() {
|
|
230
|
return timeLimitWithOrgMailRetrivePassword;
|
|
231
|
}
|
|
232
|
|
|
233
|
public void setTimeLimitWithOrgMailRetrivePassword(long timeLimitWithOrgMailRetrivePassword) {
|
|
234
|
this.timeLimitWithOrgMailRetrivePassword = timeLimitWithOrgMailRetrivePassword;
|
|
235
|
}
|
|
236
|
|
200
|
237
|
public String getBindMobilePhoneReplaceKey() {
|
201
|
238
|
return bindMobilePhoneReplaceKey;
|
202
|
239
|
}
|
|
@ -1140,6 +1177,54 @@ public class SysService {
|
1140
|
1177
|
}
|
1141
|
1178
|
}
|
1142
|
1179
|
|
|
1180
|
@Get
|
|
1181
|
@Path("/resetWithOrgEmail")
|
|
1182
|
public boolean resetWithOrgEmail(@JdbcConn(false) Connection con, String mail) throws JfwBaseException, SQLException {
|
|
1183
|
OrgUser orgUser = this.orgUserDao.queryByEmail(con, mail);
|
|
1184
|
if (orgUser == null)
|
|
1185
|
return false;
|
|
1186
|
StateCode<String, String> sc = new StateCode<String, String>();
|
|
1187
|
sc.setKey(orgUser.getId());
|
|
1188
|
sc.setValue(mail);
|
|
1189
|
final String key = JfwAppContext.cacheObjectAndGenKey(sc);
|
|
1190
|
Map<String, String> map = new HashMap<String, String>();
|
|
1191
|
map.put(this.orgMailRetrievePasswordReplaceKey, key);
|
|
1192
|
try {
|
|
1193
|
mailservice.sendSimpleMail(mail, this.orgMailRetrievePasswordContentTemplate, map, this.orgMailRetrievePasswordSubject);
|
|
1194
|
long ct = System.currentTimeMillis();
|
|
1195
|
long et = ct + this.timeLimitWithOrgMailRetrivePassword + 10000;
|
|
1196
|
sc.setBuildTime(ct);
|
|
1197
|
sc.setExpiredTime(et);
|
|
1198
|
JfwAppContext.getScheduledExecutorService().schedule(new Runnable() {
|
|
1199
|
@Override
|
|
1200
|
public void run() {
|
|
1201
|
JfwAppContext.removeCachedObject(key);
|
|
1202
|
}
|
|
1203
|
}, this.timeLimitWithOrgMailRetrivePassword + 20000, TimeUnit.MILLISECONDS);
|
|
1204
|
} catch (Exception e) {
|
|
1205
|
JfwAppContext.removeCachedObject(key);
|
|
1206
|
throw new JfwBaseException(10011, "send mail to " + mail + " error", e);
|
|
1207
|
}
|
|
1208
|
return true;
|
|
1209
|
}
|
|
1210
|
|
|
1211
|
@Post
|
|
1212
|
@Path("/resetPwByOrgEmail")
|
|
1213
|
public boolean resetPwByOrgEmail(@JdbcConn(true) Connection con, String state, String pw) throws SQLException, JfwBaseException {
|
|
1214
|
@SuppressWarnings("unchecked")
|
|
1215
|
StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext.getCachedObject(state);
|
|
1216
|
if (sc == null)
|
|
1217
|
throw new JfwBaseException("验证超时");
|
|
1218
|
if (sc.getExpiredTime() < System.currentTimeMillis())
|
|
1219
|
throw new JfwBaseException("验证超时");
|
|
1220
|
String key = sc.getKey();
|
|
1221
|
try {
|
|
1222
|
return this.orgUserDao.updatePasswd(con, key, StringUtil.md5(pw)) > 0;
|
|
1223
|
} finally {
|
|
1224
|
JfwAppContext.removeCachedObject(state);
|
|
1225
|
}
|
|
1226
|
}
|
|
1227
|
|
1143
|
1228
|
/**
|
1144
|
1229
|
* 给指定邮箱发送邀请邮件
|
1145
|
1230
|
* @param con
|