|
@ -50,6 +50,7 @@ public class SysService {
|
50
|
50
|
private String bindMailReplaceContentTempalte;
|
51
|
51
|
private long timeLimitWithBindMail = 10 * 60 * 1000;
|
52
|
52
|
|
|
53
|
private String regMailSubject = "注册[科袖网]用户";
|
53
|
54
|
private String regMailReplaceKey;
|
54
|
55
|
private String regMailReplaceContentTempalte;
|
55
|
56
|
private long timeLimitWithRegMail = 10 * 60 * 1000;
|
|
@ -70,7 +71,7 @@ public class SysService {
|
70
|
71
|
private String regMobilePhoneReplaceKey;
|
71
|
72
|
private String regMobilePhoneContentTemplate;
|
72
|
73
|
private long timeLimitWithRegMobilePhone = 3 * 60 * 1000;
|
73
|
|
|
|
74
|
|
74
|
75
|
private String phoneContentTemplate;
|
75
|
76
|
private String phoneReplaceKey = "mobileCode";
|
76
|
77
|
private String inviteReplacePhone = "phoneKey";
|
|
@ -91,8 +92,7 @@ public class SysService {
|
91
|
92
|
return regMailReplaceContentTempalte;
|
92
|
93
|
}
|
93
|
94
|
|
94
|
|
public void setRegMailReplaceContentTempalte(
|
95
|
|
String regMailReplaceContentTempalte) {
|
|
95
|
public void setRegMailReplaceContentTempalte(String regMailReplaceContentTempalte) {
|
96
|
96
|
this.regMailReplaceContentTempalte = regMailReplaceContentTempalte;
|
97
|
97
|
}
|
98
|
98
|
|
|
@ -116,8 +116,7 @@ public class SysService {
|
116
|
116
|
return regMobilePhoneContentTemplate;
|
117
|
117
|
}
|
118
|
118
|
|
119
|
|
public void setRegMobilePhoneContentTemplate(
|
120
|
|
String regMobilePhoneContentTemplate) {
|
|
119
|
public void setRegMobilePhoneContentTemplate(String regMobilePhoneContentTemplate) {
|
121
|
120
|
this.regMobilePhoneContentTemplate = regMobilePhoneContentTemplate;
|
122
|
121
|
}
|
123
|
122
|
|
|
@ -133,8 +132,7 @@ public class SysService {
|
133
|
132
|
return mailRetrievePasswordSubject;
|
134
|
133
|
}
|
135
|
134
|
|
136
|
|
public void setMailRetrievePasswordSubject(
|
137
|
|
String mailRetrievePasswordSubject) {
|
|
135
|
public void setMailRetrievePasswordSubject(String mailRetrievePasswordSubject) {
|
138
|
136
|
this.mailRetrievePasswordSubject = mailRetrievePasswordSubject;
|
139
|
137
|
}
|
140
|
138
|
|
|
@ -150,8 +148,7 @@ public class SysService {
|
150
|
148
|
return phoneRetrievePasswordReplaceKey;
|
151
|
149
|
}
|
152
|
150
|
|
153
|
|
public void setPhoneRetrievePasswordReplaceKey(
|
154
|
|
String phoneRetrievePasswordReplaceKey) {
|
|
151
|
public void setPhoneRetrievePasswordReplaceKey(String phoneRetrievePasswordReplaceKey) {
|
155
|
152
|
this.phoneRetrievePasswordReplaceKey = phoneRetrievePasswordReplaceKey;
|
156
|
153
|
}
|
157
|
154
|
|
|
@ -159,8 +156,7 @@ public class SysService {
|
159
|
156
|
return phoneRetrievePasswordContentTemplate;
|
160
|
157
|
}
|
161
|
158
|
|
162
|
|
public void setPhoneRetrievePasswordContentTemplate(
|
163
|
|
String phoneRetrievePasswordContentTemplate) {
|
|
159
|
public void setPhoneRetrievePasswordContentTemplate(String phoneRetrievePasswordContentTemplate) {
|
164
|
160
|
this.phoneRetrievePasswordContentTemplate = phoneRetrievePasswordContentTemplate;
|
165
|
161
|
}
|
166
|
162
|
|
|
@ -168,8 +164,7 @@ public class SysService {
|
168
|
164
|
return timeLimitWithPhoneRetrievePassword;
|
169
|
165
|
}
|
170
|
166
|
|
171
|
|
public void setTimeLimitWithPhoneRetrievePassword(
|
172
|
|
long timeLimitWithPhoneRetrievePassword) {
|
|
167
|
public void setTimeLimitWithPhoneRetrievePassword(long timeLimitWithPhoneRetrievePassword) {
|
173
|
168
|
this.timeLimitWithPhoneRetrievePassword = timeLimitWithPhoneRetrievePassword;
|
174
|
169
|
}
|
175
|
170
|
|
|
@ -177,8 +172,7 @@ public class SysService {
|
177
|
172
|
return timeLimitWithMailRetrivePassword;
|
178
|
173
|
}
|
179
|
174
|
|
180
|
|
public void setTimeLimitWithMailRetrivePassword(
|
181
|
|
long timeLimitWithMailRetrivePassword) {
|
|
175
|
public void setTimeLimitWithMailRetrivePassword(long timeLimitWithMailRetrivePassword) {
|
182
|
176
|
this.timeLimitWithMailRetrivePassword = timeLimitWithMailRetrivePassword;
|
183
|
177
|
}
|
184
|
178
|
|
|
@ -194,8 +188,7 @@ public class SysService {
|
194
|
188
|
return bindMobilePhoneContentTemplate;
|
195
|
189
|
}
|
196
|
190
|
|
197
|
|
public void setBindMobilePhoneContentTemplate(
|
198
|
|
String bindMobilePhoneContentTemplate) {
|
|
191
|
public void setBindMobilePhoneContentTemplate(String bindMobilePhoneContentTemplate) {
|
199
|
192
|
this.bindMobilePhoneContentTemplate = bindMobilePhoneContentTemplate;
|
200
|
193
|
}
|
201
|
194
|
|
|
@ -203,13 +196,11 @@ public class SysService {
|
203
|
196
|
return timeLimitWithBindMobilePhone;
|
204
|
197
|
}
|
205
|
198
|
|
206
|
|
public void setTimeLimitWithBindMobilePhone(
|
207
|
|
long timeLimitWithBindMobilePhone) {
|
|
199
|
public void setTimeLimitWithBindMobilePhone(long timeLimitWithBindMobilePhone) {
|
208
|
200
|
this.timeLimitWithBindMobilePhone = timeLimitWithBindMobilePhone;
|
209
|
201
|
}
|
210
|
202
|
|
211
|
|
public void setMailRetrievePasswordContentTemplate(
|
212
|
|
String retrievePasswordContentTemplate) {
|
|
203
|
public void setMailRetrievePasswordContentTemplate(String retrievePasswordContentTemplate) {
|
213
|
204
|
this.mailRetrievePasswordContentTemplate = retrievePasswordContentTemplate;
|
214
|
205
|
}
|
215
|
206
|
|
|
@ -233,8 +224,7 @@ public class SysService {
|
233
|
224
|
return mailRetrievePasswordReplaceKey;
|
234
|
225
|
}
|
235
|
226
|
|
236
|
|
public void setMailRetrievePasswordReplaceKey(
|
237
|
|
String retrievePasswordReplaceKey) {
|
|
227
|
public void setMailRetrievePasswordReplaceKey(String retrievePasswordReplaceKey) {
|
238
|
228
|
this.mailRetrievePasswordReplaceKey = retrievePasswordReplaceKey;
|
239
|
229
|
}
|
240
|
230
|
|
|
@ -254,8 +244,7 @@ public class SysService {
|
254
|
244
|
return bindMailReplaceContentTempalte;
|
255
|
245
|
}
|
256
|
246
|
|
257
|
|
public void setBindMailReplaceContentTempalte(
|
258
|
|
String bindMailReplaceContentTempalte) {
|
|
247
|
public void setBindMailReplaceContentTempalte(String bindMailReplaceContentTempalte) {
|
259
|
248
|
this.bindMailReplaceContentTempalte = bindMailReplaceContentTempalte;
|
260
|
249
|
}
|
261
|
250
|
|
|
@ -339,24 +328,32 @@ public class SysService {
|
339
|
328
|
this.mailservice = mailservice;
|
340
|
329
|
}
|
341
|
330
|
|
|
331
|
public String getRegMailSubject() {
|
|
332
|
return regMailSubject;
|
|
333
|
}
|
|
334
|
|
|
335
|
public void setRegMailSubject(String regMailSubject) {
|
|
336
|
this.regMailSubject = regMailSubject;
|
|
337
|
}
|
|
338
|
|
342
|
339
|
@Get
|
343
|
340
|
@Path("/getMD5")
|
344
|
|
public String getUUID(@JdbcConn Connection con, String pass)
|
345
|
|
throws SQLException {
|
|
341
|
public String getUUID(@JdbcConn Connection con, String pass) throws SQLException {
|
346
|
342
|
return StringUtil.md5(pass);
|
347
|
343
|
}
|
348
|
|
|
|
344
|
|
349
|
345
|
/**
|
350
|
346
|
* 验证注册时填写的手机号和邮箱是否已经注册过
|
|
347
|
*
|
351
|
348
|
* @param con
|
352
|
|
* @param key 手机号或邮箱
|
|
349
|
* @param key
|
|
350
|
* 手机号或邮箱
|
353
|
351
|
* @return 如果该手机或邮箱已经注册过返回false, 否则返回true
|
354
|
352
|
* @throws SQLException
|
355
|
353
|
*/
|
356
|
354
|
@Get
|
357
|
355
|
@Path("/isReg")
|
358
|
|
public boolean isReg(@JdbcConn Connection con, String key)
|
359
|
|
throws SQLException {
|
|
356
|
public boolean isReg(@JdbcConn Connection con, String key) throws SQLException {
|
360
|
357
|
User user = this.userDao.queryByEmailOrMobilePhone(con, key);
|
361
|
358
|
if (null != user) {
|
362
|
359
|
return false;
|
|
@ -364,11 +361,11 @@ public class SysService {
|
364
|
361
|
return true;
|
365
|
362
|
}
|
366
|
363
|
}
|
367
|
|
|
|
364
|
|
368
|
365
|
@Get
|
369
|
366
|
@Path("/qaUser")
|
370
|
|
public User queryUser(@JdbcConn Connection con, String id) throws SQLException{
|
371
|
|
User user = this.userDao.query(con, id);
|
|
367
|
public User queryUser(@JdbcConn Connection con, String id) throws SQLException {
|
|
368
|
User user = this.userDao.query(con, id);
|
372
|
369
|
User user2 = new User();
|
373
|
370
|
user2.setId(user.getId());
|
374
|
371
|
user2.setMobilePhone(user.getMobilePhone());
|
|
@ -390,16 +387,14 @@ public class SysService {
|
390
|
387
|
* 注册密码
|
391
|
388
|
* @return
|
392
|
389
|
* @throws SQLException
|
393
|
|
* @throws JfwBaseException
|
|
390
|
* @throws JfwBaseException
|
394
|
391
|
*/
|
395
|
392
|
@Post
|
396
|
393
|
@Path("/regmobile")
|
397
|
|
public String regMobile(@JdbcConn(true) Connection con, String state,
|
398
|
|
String mobilePhone, String validateCode, String password)
|
|
394
|
public String regMobile(@JdbcConn(true) Connection con, String state, String mobilePhone, String validateCode, String password, @Nullable String inviterId)
|
399
|
395
|
throws SQLException, JfwBaseException {
|
400
|
396
|
@SuppressWarnings("unchecked")
|
401
|
|
StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext
|
402
|
|
.getCachedObject(state);
|
|
397
|
StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext.getCachedObject(state);
|
403
|
398
|
if (sc == null)
|
404
|
399
|
return "验证超时";
|
405
|
400
|
if (sc.getExpiredTime() < System.currentTimeMillis())
|
|
@ -416,7 +411,8 @@ public class SysService {
|
416
|
411
|
String passwd = StringUtil.md5(password);
|
417
|
412
|
user.setMobilePhone(mobilePhone);
|
418
|
413
|
user.setPasswd(passwd);
|
419
|
|
user.setUserType(0 + "");
|
|
414
|
user.setUserType("0");
|
|
415
|
user.setInviterId(inviterId);
|
420
|
416
|
this.userDao.insert(con, user);
|
421
|
417
|
return user.getId();
|
422
|
418
|
} finally {
|
|
@ -430,48 +426,38 @@ public class SysService {
|
430
|
426
|
* @param con
|
431
|
427
|
* @param key
|
432
|
428
|
* 发送邮箱验证的返回值
|
433
|
|
* @param mail
|
434
|
|
* 验证的邮箱地址
|
|
429
|
*
|
435
|
430
|
* @return 验证成功 用户登录并返回用户信息 验证失败返回null
|
436
|
431
|
* @throws SQLException
|
437
|
|
* @throws JfwBaseException
|
|
432
|
* @throws JfwBaseException
|
438
|
433
|
*/
|
439
|
|
@SetCookie(checkResultNull = true, path = "/", value = {
|
440
|
|
"userid=result.getId()", "userMobilePhone=result.getMobilePhone()",
|
441
|
|
"userType=result.getType()",
|
442
|
|
"userAuth=String.valueOf(result.isAuth())",
|
443
|
|
"userEmail=result.getEmail()==null?\"\":result.getEmail()",
|
444
|
|
"userName=result.getName()==null?\"\":java.net.URLEncoder.encode(result.getName(),\"utf-8\")"
|
445
|
|
})
|
446
|
|
@Post
|
|
434
|
@Get
|
447
|
435
|
@Path("/regmail/{key}")
|
448
|
|
public SessionUser regeMail(@JdbcConn(true) Connection con, @PathVar String key, String mail,
|
449
|
|
String userId) throws SQLException, JfwBaseException {
|
|
436
|
public void regeMail(@JdbcConn(false) Connection con, @PathVar String key) throws SQLException, JfwBaseException {
|
450
|
437
|
@SuppressWarnings("unchecked")
|
451
|
|
StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext
|
452
|
|
.getCachedObject(key);
|
453
|
|
if (sc == null) {
|
454
|
|
this.userDao.delete(con, userId);
|
455
|
|
throw new JfwBaseException("验证超时");
|
456
|
|
}
|
457
|
|
if (sc.getExpiredTime() < System.currentTimeMillis()) {
|
458
|
|
this.userDao.delete(con, userId);
|
459
|
|
throw new JfwBaseException("验证超时");
|
|
438
|
StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext.getCachedObject(key);
|
|
439
|
if (sc == null || sc.getExpiredTime() < System.currentTimeMillis()) {
|
|
440
|
throw new JfwBaseException(-1, "验证链接已失效");
|
460
|
441
|
}
|
461
|
442
|
try {
|
462
|
|
User user = userDao.queryByEmailOrMobilePhone(con, mail);
|
463
|
|
if (null == user)
|
464
|
|
return null;
|
465
|
|
SessionUser ret = new SessionUser();
|
466
|
|
ret.setId(user.getId());
|
467
|
|
if (null != this.professorDao.query(con, user.getId())) {
|
468
|
|
ret.setName(this.professorDao.query(con, user.getId()).getName());
|
|
443
|
User user = new User();
|
|
444
|
user.setEmail(sc.getCode());
|
|
445
|
user.setId(StringUtil.buildUUID());
|
|
446
|
user.setSendMailStatus(0);
|
|
447
|
user.setPasswd(StringUtil.md5(sc.getKey()));
|
|
448
|
user.setUserType("0");
|
|
449
|
user.setInviterId(sc.getValue());
|
|
450
|
this.userDao.insert(con, user);
|
|
451
|
con.commit();
|
|
452
|
} catch (SQLException e) {
|
|
453
|
try {
|
|
454
|
con.rollback();
|
|
455
|
} catch (Exception ee) {
|
|
456
|
}
|
|
457
|
if ("23505".equals(e.getSQLState())) {
|
|
458
|
throw new JfwBaseException(-3, "邮箱[" + sc.getCode() + "]已被注册过了");
|
469
|
459
|
}
|
470
|
|
ret.setMobilePhone(user.getMobilePhone());
|
471
|
|
ret.setType(user.getUserType());
|
472
|
|
ret.setEmail(user.getEmail());
|
473
|
|
ret.setAuth(true);
|
474
|
|
return ret;
|
|
460
|
throw e;
|
475
|
461
|
} finally {
|
476
|
462
|
JfwAppContext.removeCachedObject(key);
|
477
|
463
|
}
|
|
@ -479,80 +465,61 @@ public class SysService {
|
479
|
465
|
|
480
|
466
|
/**
|
481
|
467
|
* 邮箱注册并发送邮箱验证
|
|
468
|
*
|
482
|
469
|
* @param con
|
483
|
|
* @param mail 待验证的邮箱地址
|
484
|
|
* @param password 密码
|
485
|
|
* @return 注册成功并发动验证返回用户ID 用户已注册返回null 邮件发送失败抛出异常
|
|
470
|
* @param mail
|
|
471
|
* 待验证的邮箱地址
|
|
472
|
* @param password
|
|
473
|
* 密码
|
486
|
474
|
* @throws JfwBaseException
|
487
|
475
|
* @throws SQLException
|
488
|
476
|
*/
|
489
|
|
@Get
|
|
477
|
@Post
|
490
|
478
|
@Path("/regmail")
|
491
|
|
public String regMail(@JdbcConn(true) Connection con, String mail,
|
492
|
|
String password) throws JfwBaseException, SQLException {
|
493
|
|
User user1 = new User();
|
|
479
|
public void regMail(@JdbcConn(false) Connection con, String mail, String password,@Nullable String inviterId) throws JfwBaseException, SQLException {
|
494
|
480
|
User user = this.userDao.queryByEmailOrMobilePhone(con, mail);
|
495
|
481
|
if (null != user) {
|
496
|
|
return null;
|
|
482
|
throw new JfwBaseException(-1, "邮箱[" + mail + "]已被注册过了");
|
497
|
483
|
} else {
|
498
|
|
user1.setId(StringUtil.buildUUID());
|
499
|
|
String passwd = StringUtil.md5(password);
|
500
|
|
user1.setEmail(mail);
|
501
|
|
user1.setPasswd(passwd);
|
502
|
|
user1.setUserType(0 + "");
|
503
|
|
this.userDao.insert(con, user1);
|
504
|
|
this.sendMailReg(con, mail);
|
505
|
|
}
|
506
|
|
return user1.getId();
|
507
|
|
}
|
508
|
|
|
509
|
|
@Get
|
510
|
|
@Path("/resendMail")
|
511
|
|
public boolean sendMailReg(@JdbcConn(false) Connection con, String mail) throws JfwBaseException {
|
512
|
|
StateCode<String, String> sc = new StateCode<String, String>();
|
513
|
|
final String key = JfwAppContext.cacheObjectAndGenKey(sc);
|
514
|
484
|
|
515
|
|
Map<String, String> map = new HashMap<String, String>();
|
516
|
|
map.put(this.regMailReplaceKey, key);
|
517
|
|
try {
|
518
|
|
mailservice.sendSimpleMail(mail,
|
519
|
|
this.regMailReplaceContentTempalte, map,
|
520
|
|
this.bindMailSubject);
|
521
|
|
long ct = System.currentTimeMillis();
|
522
|
|
long et = ct + this.timeLimitWithRegMail + 10000;
|
523
|
|
sc.setBuildTime(ct);
|
524
|
|
sc.setExpiredTime(et);
|
525
|
|
JfwAppContext.getScheduledExecutorService().schedule(
|
526
|
|
new Runnable() {
|
527
|
|
@Override
|
528
|
|
public void run() {
|
529
|
|
JfwAppContext.removeCachedObject(key);
|
530
|
|
}
|
531
|
|
}, this.timeLimitWithRegMail + 20000,
|
532
|
|
TimeUnit.MILLISECONDS);
|
533
|
|
} catch (Exception e) {
|
534
|
|
JfwAppContext.removeCachedObject(key);
|
535
|
|
throw new JfwBaseException(10011, "send mail to " + mail
|
536
|
|
+ " error", e);
|
|
485
|
StateCode<String, String> sc = new StateCode<String, String>();
|
|
486
|
final String key = JfwAppContext.cacheObjectAndGenKey(sc);
|
|
487
|
Map<String, String> map = new HashMap<>();
|
|
488
|
map.put(this.regMailReplaceKey, key);
|
|
489
|
try {
|
|
490
|
this.mailservice.sendSimpleMail(mail, this.regMailReplaceContentTempalte, map, this.regMailSubject);
|
|
491
|
} catch (MessagingException e) {
|
|
492
|
JfwAppContext.removeCachedObject(key);
|
|
493
|
throw new JfwBaseException(-2, "给邮箱[" + mail + "]发邮件错误", e);
|
|
494
|
}
|
|
495
|
sc.setCode(mail);
|
|
496
|
sc.setKey(password);
|
|
497
|
sc.setValue(inviterId);
|
|
498
|
sc.setBuildTime(System.currentTimeMillis());
|
|
499
|
sc.setExpiredTime(sc.getBuildTime() + this.timeLimitWithRegMail);
|
|
500
|
JfwAppContext.getScheduledExecutorService().schedule(new Runnable() {
|
|
501
|
@Override
|
|
502
|
public void run() {
|
|
503
|
JfwAppContext.removeCachedObject(key);
|
|
504
|
}
|
|
505
|
}, this.timeLimitWithRegMail, TimeUnit.MILLISECONDS);
|
537
|
506
|
}
|
538
|
|
return true;
|
539
|
507
|
}
|
540
|
|
|
|
508
|
|
541
|
509
|
@Get
|
542
|
510
|
@Path("/sendMailInvite")
|
543
|
|
public String sendMailInvite(@JdbcConn(false) Connection con,String id)
|
544
|
|
throws SQLException, MessagingException, JfwBaseException {
|
|
511
|
public String sendMailInvite(@JdbcConn(false) Connection con, String id) throws SQLException, MessagingException, JfwBaseException {
|
545
|
512
|
User user = this.userDao.query(con, id);
|
546
|
|
if(user == null){
|
|
513
|
if (user == null) {
|
547
|
514
|
throw new JfwBaseException("系统没有此用户");
|
548
|
515
|
}
|
549
|
|
if(user.getEmail() == null){
|
|
516
|
if (user.getEmail() == null) {
|
550
|
517
|
throw new JfwBaseException("邮箱不能为空");
|
551
|
518
|
}
|
552
|
|
if(user.getInviteCode() == null){
|
|
519
|
if (user.getInviteCode() == null) {
|
553
|
520
|
throw new JfwBaseException("该用户没有邀请码");
|
554
|
521
|
}
|
555
|
|
if(user != null && user.getEmail() != null && user.getInviteCode() != null){
|
|
522
|
if (user != null && user.getEmail() != null && user.getInviteCode() != null) {
|
556
|
523
|
}
|
557
|
524
|
String mailContent = this.inviteMailContentTempalte;
|
558
|
525
|
mailContent = mailContent.replaceAll(this.inviteReplaceEmail, user.getEmail());
|
|
@ -567,17 +534,13 @@ public class SysService {
|
567
|
534
|
this.mailservice.sendSimpleMail(user.getEmail(), mailContent, null, this.inviteMailSubject);
|
568
|
535
|
return "send success !";
|
569
|
536
|
}
|
570
|
|
|
571
|
|
@SetCookie(checkResultNull = true, path = "/", value = {
|
572
|
|
"userid=result.getId()", "userMobilePhone=result.getMobilePhone()",
|
573
|
|
"userType=result.getType()",
|
574
|
|
"userAuth=String.valueOf(result.isAuth())",
|
575
|
|
"userEmail=result.getEmail()==null?\"\":result.getEmail()",
|
576
|
|
"userName=result.getName()==null?\"\":java.net.URLEncoder.encode(result.getName(),\"utf-8\")"
|
577
|
|
})
|
|
537
|
|
|
538
|
@SetCookie(checkResultNull = true, path = "/", value = { "userid=result.getId()", "userMobilePhone=result.getMobilePhone()", "userType=result.getType()",
|
|
539
|
"userAuth=String.valueOf(result.isAuth())", "userEmail=result.getEmail()==null?\"\":result.getEmail()",
|
|
540
|
"userName=result.getName()==null?\"\":java.net.URLEncoder.encode(result.getName(),\"utf-8\")" })
|
578
|
541
|
@Post
|
579
|
542
|
@Path("/invitelogin")
|
580
|
|
public SessionUser inviteLogin(@JdbcConn Connection con,String key,String code) throws SQLException {
|
|
543
|
public SessionUser inviteLogin(@JdbcConn Connection con, String key, String code) throws SQLException {
|
581
|
544
|
User user = userDao.queryByEmailOrMobilePhone(con, key);
|
582
|
545
|
if (null == user) {
|
583
|
546
|
return null;
|
|
@ -596,17 +559,12 @@ public class SysService {
|
596
|
559
|
return ret;
|
597
|
560
|
}
|
598
|
561
|
|
599
|
|
@SetCookie(checkResultNull = true, path = "/", value = {
|
600
|
|
"userid=result.getId()", "userMobilePhone=result.getMobilePhone()",
|
601
|
|
"userType=result.getType()",
|
602
|
|
"userAuth=String.valueOf(result.isAuth())",
|
603
|
|
"userEmail=result.getEmail()==null?\"\":result.getEmail()",
|
604
|
|
"userName=result.getName()==null?\"\":java.net.URLEncoder.encode(result.getName(),\"utf-8\")"
|
605
|
|
})
|
|
562
|
@SetCookie(checkResultNull = true, path = "/", value = { "userid=result.getId()", "userMobilePhone=result.getMobilePhone()", "userType=result.getType()",
|
|
563
|
"userAuth=String.valueOf(result.isAuth())", "userEmail=result.getEmail()==null?\"\":result.getEmail()",
|
|
564
|
"userName=result.getName()==null?\"\":java.net.URLEncoder.encode(result.getName(),\"utf-8\")" })
|
606
|
565
|
@Post
|
607
|
566
|
@Path("/slogin")
|
608
|
|
public SessionUser sLogin(@JdbcConn Connection con, String code,
|
609
|
|
String mobile) throws SQLException {
|
|
567
|
public SessionUser sLogin(@JdbcConn Connection con, String code, String mobile) throws SQLException {
|
610
|
568
|
User user = userDao.query(con, code);
|
611
|
569
|
if (null == user)
|
612
|
570
|
return null;
|
|
@ -623,20 +581,15 @@ public class SysService {
|
623
|
581
|
return ret;
|
624
|
582
|
}
|
625
|
583
|
|
626
|
|
@SetCookie(checkResultNull = true, path = "/", value = {
|
627
|
|
"userid=result.getId()", "userMobilePhone=result.getMobilePhone()",
|
628
|
|
"userType=result.getType()",
|
629
|
|
"userAuth=String.valueOf(result.isAuth())",
|
630
|
|
"userEmail=result.getEmail()==null?\"\":result.getEmail()",
|
631
|
|
"userName=result.getName()==null?\"\":java.net.URLEncoder.encode(result.getName(),\"utf-8\")"
|
632
|
|
})
|
|
584
|
@SetCookie(checkResultNull = true, path = "/", value = { "userid=result.getId()", "userMobilePhone=result.getMobilePhone()", "userType=result.getType()",
|
|
585
|
"userAuth=String.valueOf(result.isAuth())", "userEmail=result.getEmail()==null?\"\":result.getEmail()",
|
|
586
|
"userName=result.getName()==null?\"\":java.net.URLEncoder.encode(result.getName(),\"utf-8\")" })
|
633
|
587
|
@Post
|
634
|
588
|
@Path("/login")
|
635
|
|
public SessionUser login(@JdbcConn Connection con, String lk, String pw)
|
636
|
|
throws SQLException,JfwBaseException {
|
|
589
|
public SessionUser login(@JdbcConn Connection con, String lk, String pw) throws SQLException, JfwBaseException {
|
637
|
590
|
User user = userDao.queryByEmailOrMobilePhone(con, lk);
|
638
|
591
|
if (null == user)
|
639
|
|
throw new JfwBaseException(-1,"该用户还未注册");
|
|
592
|
throw new JfwBaseException(-1, "该用户还未注册");
|
640
|
593
|
if (DEFAULT_PASS_WORD.equals(user.getPasswd()))
|
641
|
594
|
return null;
|
642
|
595
|
if (!StringUtil.md5(pw).equals(user.getPasswd()))
|
|
@ -644,8 +597,8 @@ public class SysService {
|
644
|
597
|
|
645
|
598
|
SessionUser ret = new SessionUser();
|
646
|
599
|
ret.setId(user.getId());
|
647
|
|
Professor pf = this.professorDao.query(con, user.getId());
|
648
|
|
if (null !=pf) {
|
|
600
|
Professor pf = this.professorDao.query(con, user.getId());
|
|
601
|
if (null != pf) {
|
649
|
602
|
ret.setName(pf.getName());
|
650
|
603
|
}
|
651
|
604
|
ret.setMobilePhone(user.getMobilePhone());
|
|
@ -657,8 +610,7 @@ public class SysService {
|
657
|
610
|
|
658
|
611
|
@Post
|
659
|
612
|
@Path("/cp")
|
660
|
|
public boolean changePw(@JdbcConn(true) Connection con, String id,
|
661
|
|
String npw, @Nullable String onw) throws SQLException {
|
|
613
|
public boolean changePw(@JdbcConn(true) Connection con, String id, String npw, @Nullable String onw) throws SQLException {
|
662
|
614
|
User user = this.userDao.query(con, id);
|
663
|
615
|
if (user == null)
|
664
|
616
|
return false;
|
|
@ -675,8 +627,7 @@ public class SysService {
|
675
|
627
|
|
676
|
628
|
@Get
|
677
|
629
|
@Path("/reqBindMail")
|
678
|
|
public boolean reqBindMail(@JdbcConn(false) Connection con, String userid,
|
679
|
|
String mail) throws JfwBaseException, SQLException {
|
|
630
|
public boolean reqBindMail(@JdbcConn(false) Connection con, String userid, String mail) throws JfwBaseException, SQLException {
|
680
|
631
|
User user = this.userDao.query(con, userid);
|
681
|
632
|
if (null == user)
|
682
|
633
|
return false;
|
|
@ -689,43 +640,36 @@ public class SysService {
|
689
|
640
|
Map<String, String> map = new HashMap<String, String>();
|
690
|
641
|
map.put(this.bindMailReplaceKey, key);
|
691
|
642
|
try {
|
692
|
|
mailservice.sendSimpleMail(mail,
|
693
|
|
this.bindMailReplaceContentTempalte, map,
|
694
|
|
this.bindMailSubject);
|
|
643
|
mailservice.sendSimpleMail(mail, this.bindMailReplaceContentTempalte, map, this.bindMailSubject);
|
695
|
644
|
long ct = System.currentTimeMillis();
|
696
|
645
|
long et = ct + this.timeLimitWithBindMail + 10000;
|
697
|
646
|
sc.setBuildTime(ct);
|
698
|
647
|
sc.setExpiredTime(et);
|
699
|
|
JfwAppContext.getScheduledExecutorService().schedule(
|
700
|
|
new Runnable() {
|
701
|
|
@Override
|
702
|
|
public void run() {
|
703
|
|
JfwAppContext.removeCachedObject(key);
|
704
|
|
}
|
705
|
|
}, this.timeLimitWithBindMail + 20000,
|
706
|
|
TimeUnit.MILLISECONDS);
|
|
648
|
JfwAppContext.getScheduledExecutorService().schedule(new Runnable() {
|
|
649
|
@Override
|
|
650
|
public void run() {
|
|
651
|
JfwAppContext.removeCachedObject(key);
|
|
652
|
}
|
|
653
|
}, this.timeLimitWithBindMail + 20000, TimeUnit.MILLISECONDS);
|
707
|
654
|
} catch (Exception e) {
|
708
|
655
|
JfwAppContext.removeCachedObject(key);
|
709
|
|
throw new JfwBaseException(10011,
|
710
|
|
"send mail to " + mail + " error", e);
|
|
656
|
throw new JfwBaseException(10011, "send mail to " + mail + " error", e);
|
711
|
657
|
}
|
712
|
658
|
return true;
|
713
|
659
|
}
|
714
|
660
|
|
715
|
661
|
@Get
|
716
|
662
|
@Path("/bindMail/{key}")
|
717
|
|
public boolean bindMail(@JdbcConn(true) Connection con, @PathVar String key)
|
718
|
|
throws SQLException, JfwBaseException {
|
|
663
|
public boolean bindMail(@JdbcConn(true) Connection con, @PathVar String key) throws SQLException, JfwBaseException {
|
719
|
664
|
@SuppressWarnings("unchecked")
|
720
|
|
StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext
|
721
|
|
.getCachedObject(key);
|
|
665
|
StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext.getCachedObject(key);
|
722
|
666
|
if (sc == null)
|
723
|
667
|
return false;
|
724
|
668
|
if (sc.getExpiredTime() < System.currentTimeMillis())
|
725
|
669
|
return false;
|
726
|
670
|
try {
|
727
|
671
|
Professor professor = this.professorDao.queryOne(con, sc.getKey());
|
728
|
|
if(professor.getPhone() == null || professor.getPhone().isEmpty()){
|
|
672
|
if (professor.getPhone() == null || professor.getPhone().isEmpty()) {
|
729
|
673
|
this.professorDao.updateEmail(con, sc.getKey(), sc.getValue());
|
730
|
674
|
}
|
731
|
675
|
return this.userDao.updateEmail(con, sc.getValue(), sc.getKey()) > 0;
|
|
@ -736,9 +680,7 @@ public class SysService {
|
736
|
680
|
|
737
|
681
|
@Get
|
738
|
682
|
@Path("/vcWithBind")
|
739
|
|
public String reqBindBindMobilePhone(@JdbcConn(false) Connection con,
|
740
|
|
String userid, String mobilePhone) throws JfwBaseException,
|
741
|
|
SQLException {
|
|
683
|
public String reqBindBindMobilePhone(@JdbcConn(false) Connection con, String userid, String mobilePhone) throws JfwBaseException, SQLException {
|
742
|
684
|
User user = this.userDao.query(con, userid);
|
743
|
685
|
if (null == user)
|
744
|
686
|
return null;
|
|
@ -757,25 +699,20 @@ public class SysService {
|
757
|
699
|
String vc = String.format("%04d", vi);
|
758
|
700
|
sc.setKey(mobilePhone);
|
759
|
701
|
sc.setValue(vc);
|
760
|
|
this.mobilePhoneServcie.sendMessage(mobilePhone,
|
761
|
|
this.bindMobilePhoneContentTemplate,
|
762
|
|
this.bindMobilePhoneReplaceKey, vc);
|
|
702
|
this.mobilePhoneServcie.sendMessage(mobilePhone, this.bindMobilePhoneContentTemplate, this.bindMobilePhoneReplaceKey, vc);
|
763
|
703
|
long ct = System.currentTimeMillis();
|
764
|
704
|
long et = ct + this.timeLimitWithBindMobilePhone + 5000;
|
765
|
705
|
sc.setBuildTime(ct);
|
766
|
706
|
sc.setExpiredTime(et);
|
767
|
|
JfwAppContext.getScheduledExecutorService().schedule(
|
768
|
|
new Runnable() {
|
769
|
|
@Override
|
770
|
|
public void run() {
|
771
|
|
JfwAppContext.removeCachedObject(key);
|
772
|
|
}
|
773
|
|
}, this.timeLimitWithBindMobilePhone + 10000,
|
774
|
|
TimeUnit.MILLISECONDS);
|
|
707
|
JfwAppContext.getScheduledExecutorService().schedule(new Runnable() {
|
|
708
|
@Override
|
|
709
|
public void run() {
|
|
710
|
JfwAppContext.removeCachedObject(key);
|
|
711
|
}
|
|
712
|
}, this.timeLimitWithBindMobilePhone + 10000, TimeUnit.MILLISECONDS);
|
775
|
713
|
} catch (Exception e) {
|
776
|
714
|
JfwAppContext.removeCachedObject(key);
|
777
|
|
throw new JfwBaseException(10012, "send mobile phone message to "
|
778
|
|
+ mobilePhone + " error", e);
|
|
715
|
throw new JfwBaseException(10012, "send mobile phone message to " + mobilePhone + " error", e);
|
779
|
716
|
}
|
780
|
717
|
return key;
|
781
|
718
|
}
|
|
@ -792,8 +729,7 @@ public class SysService {
|
792
|
729
|
*/
|
793
|
730
|
@Get
|
794
|
731
|
@Path("/regmobilephone")
|
795
|
|
public String regMobilePhone(@JdbcConn(false) Connection con,
|
796
|
|
String mobilePhone) throws JfwBaseException, SQLException {
|
|
732
|
public String regMobilePhone(@JdbcConn(false) Connection con, String mobilePhone) throws JfwBaseException, SQLException {
|
797
|
733
|
User user = this.userDao.queryByEmailOrMobilePhone(con, mobilePhone);
|
798
|
734
|
if (null != user) {
|
799
|
735
|
return null;
|
|
@ -810,47 +746,39 @@ public class SysService {
|
810
|
746
|
String vc = String.format("%04d", vi);
|
811
|
747
|
sc.setKey(mobilePhone);
|
812
|
748
|
sc.setValue(vc);
|
813
|
|
this.mobilePhoneServcie.sendMessage(mobilePhone,
|
814
|
|
this.regMobilePhoneContentTemplate,
|
815
|
|
this.regMobilePhoneReplaceKey, vc);
|
|
749
|
this.mobilePhoneServcie.sendMessage(mobilePhone, this.regMobilePhoneContentTemplate, this.regMobilePhoneReplaceKey, vc);
|
816
|
750
|
long ct = System.currentTimeMillis();
|
817
|
751
|
long et = ct + this.timeLimitWithRegMobilePhone + 5000;
|
818
|
752
|
sc.setBuildTime(ct);
|
819
|
753
|
sc.setExpiredTime(et);
|
820
|
|
JfwAppContext.getScheduledExecutorService().schedule(
|
821
|
|
new Runnable() {
|
822
|
|
@Override
|
823
|
|
public void run() {
|
824
|
|
JfwAppContext.removeCachedObject(key);
|
825
|
|
}
|
826
|
|
}, this.timeLimitWithRegMobilePhone + 10000,
|
827
|
|
TimeUnit.MILLISECONDS);
|
|
754
|
JfwAppContext.getScheduledExecutorService().schedule(new Runnable() {
|
|
755
|
@Override
|
|
756
|
public void run() {
|
|
757
|
JfwAppContext.removeCachedObject(key);
|
|
758
|
}
|
|
759
|
}, this.timeLimitWithRegMobilePhone + 10000, TimeUnit.MILLISECONDS);
|
828
|
760
|
} catch (Exception e) {
|
829
|
761
|
JfwAppContext.removeCachedObject(key);
|
830
|
|
throw new JfwBaseException(10012, "send mobile phone message to "
|
831
|
|
+ mobilePhone + " error", e);
|
|
762
|
throw new JfwBaseException(10012, "send mobile phone message to " + mobilePhone + " error", e);
|
832
|
763
|
}
|
833
|
764
|
return key;
|
834
|
765
|
}
|
835
|
766
|
|
836
|
767
|
@Post
|
837
|
768
|
@Path("/bindMobilePhone")
|
838
|
|
public boolean bindMobilePhone(@JdbcConn(true) Connection con,
|
839
|
|
String state, String userid, String mobilePhone, String validateCode)
|
|
769
|
public boolean bindMobilePhone(@JdbcConn(true) Connection con, String state, String userid, String mobilePhone, String validateCode)
|
840
|
770
|
throws SQLException, JfwBaseException {
|
841
|
771
|
@SuppressWarnings("unchecked")
|
842
|
|
StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext
|
843
|
|
.getCachedObject(state);
|
|
772
|
StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext.getCachedObject(state);
|
844
|
773
|
if (sc == null)
|
845
|
774
|
return false;
|
846
|
775
|
if (sc.getExpiredTime() < System.currentTimeMillis())
|
847
|
776
|
return false;
|
848
|
777
|
try {
|
849
|
|
if (!sc.getKey().equals(mobilePhone)
|
850
|
|
|| !sc.getValue().equals(validateCode))
|
|
778
|
if (!sc.getKey().equals(mobilePhone) || !sc.getValue().equals(validateCode))
|
851
|
779
|
return false;
|
852
|
780
|
Professor professor = this.professorDao.queryOne(con, userid);
|
853
|
|
if(professor.getPhone() == null || professor.getPhone().isEmpty()){
|
|
781
|
if (professor.getPhone() == null || professor.getPhone().isEmpty()) {
|
854
|
782
|
this.professorDao.updatePhone(con, userid, mobilePhone);
|
855
|
783
|
}
|
856
|
784
|
return this.userDao.updateMobilePhone(con, mobilePhone, userid) > 0;
|
|
@ -861,8 +789,7 @@ public class SysService {
|
861
|
789
|
|
862
|
790
|
@Get
|
863
|
791
|
@Path("/vcWithRP")
|
864
|
|
public String rePassWordWithPhone(@JdbcConn(false) Connection con,
|
865
|
|
String mobilePhone) throws JfwBaseException, SQLException {
|
|
792
|
public String rePassWordWithPhone(@JdbcConn(false) Connection con, String mobilePhone) throws JfwBaseException, SQLException {
|
866
|
793
|
|
867
|
794
|
User user = this.userDao.queryByEmailOrMobilePhone(con, mobilePhone);
|
868
|
795
|
if (null == user)
|
|
@ -877,25 +804,20 @@ public class SysService {
|
877
|
804
|
String vc = String.format("%04d", vi);
|
878
|
805
|
sc.setKey(mobilePhone);
|
879
|
806
|
sc.setValue(vc);
|
880
|
|
this.mobilePhoneServcie.sendMessage(mobilePhone,
|
881
|
|
this.phoneRetrievePasswordContentTemplate,
|
882
|
|
this.phoneRetrievePasswordReplaceKey, vc);
|
|
807
|
this.mobilePhoneServcie.sendMessage(mobilePhone, this.phoneRetrievePasswordContentTemplate, this.phoneRetrievePasswordReplaceKey, vc);
|
883
|
808
|
long ct = System.currentTimeMillis();
|
884
|
809
|
long et = ct + this.timeLimitWithPhoneRetrievePassword + 5000;
|
885
|
810
|
sc.setBuildTime(ct);
|
886
|
811
|
sc.setExpiredTime(et);
|
887
|
|
JfwAppContext.getScheduledExecutorService().schedule(
|
888
|
|
new Runnable() {
|
889
|
|
@Override
|
890
|
|
public void run() {
|
891
|
|
JfwAppContext.removeCachedObject(key);
|
892
|
|
}
|
893
|
|
}, this.timeLimitWithPhoneRetrievePassword + 10000,
|
894
|
|
TimeUnit.MILLISECONDS);
|
|
812
|
JfwAppContext.getScheduledExecutorService().schedule(new Runnable() {
|
|
813
|
@Override
|
|
814
|
public void run() {
|
|
815
|
JfwAppContext.removeCachedObject(key);
|
|
816
|
}
|
|
817
|
}, this.timeLimitWithPhoneRetrievePassword + 10000, TimeUnit.MILLISECONDS);
|
895
|
818
|
} catch (Exception e) {
|
896
|
819
|
JfwAppContext.removeCachedObject(key);
|
897
|
|
throw new JfwBaseException(10012, "send mobile phone message to "
|
898
|
|
+ mobilePhone + " error", e);
|
|
820
|
throw new JfwBaseException(10012, "send mobile phone message to " + mobilePhone + " error", e);
|
899
|
821
|
}
|
900
|
822
|
return key;
|
901
|
823
|
}
|
|
@ -904,8 +826,7 @@ public class SysService {
|
904
|
826
|
@Path("/validCode")
|
905
|
827
|
public boolean validCode(String state, String vc) throws JfwBaseException {
|
906
|
828
|
@SuppressWarnings("unchecked")
|
907
|
|
StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext
|
908
|
|
.getCachedObject(state);
|
|
829
|
StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext.getCachedObject(state);
|
909
|
830
|
if (sc == null) {
|
910
|
831
|
throw new JfwBaseException("验证超时");
|
911
|
832
|
}
|
|
@ -914,22 +835,22 @@ public class SysService {
|
914
|
835
|
}
|
915
|
836
|
return sc.getValue().equals(vc);
|
916
|
837
|
}
|
917
|
|
|
|
838
|
|
918
|
839
|
@Post
|
919
|
840
|
@Path("/checkPicture")
|
920
|
|
public boolean checkPictureVC(@SessionVal(value = "verification",defaultvalue="null",remove=true) String verification,
|
921
|
|
String submitVerification) throws JfwBaseException {
|
922
|
|
if(null==verification){throw new JfwBaseException("Picture is expire !");}
|
|
841
|
public boolean checkPictureVC(@SessionVal(value = "verification", defaultvalue = "null", remove = true) String verification, String submitVerification)
|
|
842
|
throws JfwBaseException {
|
|
843
|
if (null == verification) {
|
|
844
|
throw new JfwBaseException("Picture is expire !");
|
|
845
|
}
|
923
|
846
|
return verification.equals(submitVerification);
|
924
|
847
|
}
|
925
|
848
|
|
926
|
849
|
@Post
|
927
|
850
|
@Path("/resetPasswordWithMobilePhone")
|
928
|
|
public boolean resetPassword(@JdbcConn(true) Connection con, String state,
|
929
|
|
String mobilePhone, String pw, String vc) throws SQLException, JfwBaseException {
|
|
851
|
public boolean resetPassword(@JdbcConn(true) Connection con, String state, String mobilePhone, String pw, String vc) throws SQLException, JfwBaseException {
|
930
|
852
|
@SuppressWarnings("unchecked")
|
931
|
|
StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext
|
932
|
|
.getCachedObject(state);
|
|
853
|
StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext.getCachedObject(state);
|
933
|
854
|
if (sc == null) {
|
934
|
855
|
throw new JfwBaseException("验证超时");
|
935
|
856
|
}
|
|
@ -939,8 +860,7 @@ public class SysService {
|
939
|
860
|
try {
|
940
|
861
|
if (!sc.getKey().equals(mobilePhone) || !sc.getValue().equals(vc))
|
941
|
862
|
return false;
|
942
|
|
return this.userDao.updatePasswordWithMobileOrEmail(con,
|
943
|
|
StringUtil.md5(pw), mobilePhone) > 0;
|
|
863
|
return this.userDao.updatePasswordWithMobileOrEmail(con, StringUtil.md5(pw), mobilePhone) > 0;
|
944
|
864
|
} finally {
|
945
|
865
|
JfwAppContext.removeCachedObject(state);
|
946
|
866
|
}
|
|
@ -948,8 +868,7 @@ public class SysService {
|
948
|
868
|
|
949
|
869
|
@Get
|
950
|
870
|
@Path("/reqRpWithEmail")
|
951
|
|
public boolean reqRpWithEmail(@JdbcConn(false) Connection con, String mail)
|
952
|
|
throws JfwBaseException, SQLException {
|
|
871
|
public boolean reqRpWithEmail(@JdbcConn(false) Connection con, String mail) throws JfwBaseException, SQLException {
|
953
|
872
|
User user = this.userDao.queryByEmailOrMobilePhone(con, mail);
|
954
|
873
|
if (user == null)
|
955
|
874
|
return false;
|
|
@ -960,25 +879,20 @@ public class SysService {
|
960
|
879
|
Map<String, String> map = new HashMap<String, String>();
|
961
|
880
|
map.put(this.mailRetrievePasswordReplaceKey, key);
|
962
|
881
|
try {
|
963
|
|
mailservice.sendSimpleMail(mail,
|
964
|
|
this.mailRetrievePasswordContentTemplate, map,
|
965
|
|
this.mailRetrievePasswordSubject);
|
|
882
|
mailservice.sendSimpleMail(mail, this.mailRetrievePasswordContentTemplate, map, this.mailRetrievePasswordSubject);
|
966
|
883
|
long ct = System.currentTimeMillis();
|
967
|
884
|
long et = ct + this.timeLimitWithMailRetrivePassword + 10000;
|
968
|
885
|
sc.setBuildTime(ct);
|
969
|
886
|
sc.setExpiredTime(et);
|
970
|
|
JfwAppContext.getScheduledExecutorService().schedule(
|
971
|
|
new Runnable() {
|
972
|
|
@Override
|
973
|
|
public void run() {
|
974
|
|
JfwAppContext.removeCachedObject(key);
|
975
|
|
}
|
976
|
|
}, this.timeLimitWithMailRetrivePassword + 20000,
|
977
|
|
TimeUnit.MILLISECONDS);
|
|
887
|
JfwAppContext.getScheduledExecutorService().schedule(new Runnable() {
|
|
888
|
@Override
|
|
889
|
public void run() {
|
|
890
|
JfwAppContext.removeCachedObject(key);
|
|
891
|
}
|
|
892
|
}, this.timeLimitWithMailRetrivePassword + 20000, TimeUnit.MILLISECONDS);
|
978
|
893
|
} catch (Exception e) {
|
979
|
894
|
JfwAppContext.removeCachedObject(key);
|
980
|
|
throw new JfwBaseException(10011,
|
981
|
|
"send mail to " + mail + " error", e);
|
|
895
|
throw new JfwBaseException(10011, "send mail to " + mail + " error", e);
|
982
|
896
|
}
|
983
|
897
|
return true;
|
984
|
898
|
}
|
|
@ -987,8 +901,7 @@ public class SysService {
|
987
|
901
|
@Path("/validMailState")
|
988
|
902
|
public boolean validMailState(String state) {
|
989
|
903
|
@SuppressWarnings("unchecked")
|
990
|
|
StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext
|
991
|
|
.getCachedObject(state);
|
|
904
|
StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext.getCachedObject(state);
|
992
|
905
|
if (sc == null)
|
993
|
906
|
return false;
|
994
|
907
|
if (sc.getExpiredTime() < System.currentTimeMillis())
|
|
@ -998,11 +911,9 @@ public class SysService {
|
998
|
911
|
|
999
|
912
|
@Post
|
1000
|
913
|
@Path("/resetPasswordWith")
|
1001
|
|
public boolean resetPassword(@JdbcConn(true) Connection con, String state,
|
1002
|
|
String pw) throws SQLException, JfwBaseException {
|
|
914
|
public boolean resetPassword(@JdbcConn(true) Connection con, String state, String pw) throws SQLException, JfwBaseException {
|
1003
|
915
|
@SuppressWarnings("unchecked")
|
1004
|
|
StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext
|
1005
|
|
.getCachedObject(state);
|
|
916
|
StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext.getCachedObject(state);
|
1006
|
917
|
if (sc == null)
|
1007
|
918
|
throw new JfwBaseException("验证超时");
|
1008
|
919
|
if (sc.getExpiredTime() < System.currentTimeMillis())
|
|
@ -1014,7 +925,7 @@ public class SysService {
|
1014
|
925
|
JfwAppContext.removeCachedObject(state);
|
1015
|
926
|
}
|
1016
|
927
|
}
|
1017
|
|
|
|
928
|
|
1018
|
929
|
public static void main(String[] args) {
|
1019
|
930
|
System.out.println(String.format("%04d", new Random().nextInt(10000)));
|
1020
|
931
|
}
|