Browse Source

修改验证超时提示信息。

zzy.zhiyuan.foxmail 8 years ago
parent
commit
807f4a25b3
1 changed files with 16 additions and 22 deletions
  1. 16 22
      src/main/java/com/ekexiu/portal/service/SysService.java

+ 16 - 22
src/main/java/com/ekexiu/portal/service/SysService.java

57
57
58
	private String phoneRetrievePasswordReplaceKey;
58
	private String phoneRetrievePasswordReplaceKey;
59
	private String phoneRetrievePasswordContentTemplate;
59
	private String phoneRetrievePasswordContentTemplate;
60
	private long timeLimitWithPhoneRetrievePassword =  60 * 1000;
60
	private long timeLimitWithPhoneRetrievePassword = 3 * 60 * 1000;
61
61
62
	private String mailRetrievePasswordContentTemplate;
62
	private String mailRetrievePasswordContentTemplate;
63
	private String mailRetrievePasswordReplaceKey;
63
	private String mailRetrievePasswordReplaceKey;
323
		StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext
323
		StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext
324
				.getCachedObject(state);
324
				.getCachedObject(state);
325
		if (sc == null)
325
		if (sc == null)
326
			return "state码错误!";
327
//			throw new JfwBaseException("state码错误!");
326
			return "验证超时";
328
		if (sc.getExpiredTime() < System.currentTimeMillis())
327
		if (sc.getExpiredTime() < System.currentTimeMillis())
329
			return "验证超时";
330
//			throw new JfwBaseException("验证超时!");
328
			return "验证超时";
331
		try {
329
		try {
332
			if (!sc.getKey().equals(mobilePhone)) {
330
			if (!sc.getKey().equals(mobilePhone)) {
333
				return "手机号与验证手机不匹配";
334
//				throw new JfwBaseException("手机号与验证手机不匹配!");
331
				return "手机号与验证手机不匹配";
335
			}
332
			}
336
			if (!sc.getValue().equals(validateCode)) {
333
			if (!sc.getValue().equals(validateCode)) {
337
				return "验证码错误";
338
//				throw new JfwBaseException("验证码错误!");
334
				return "验证码错误";
339
			}
335
			}
340
			User user = new User();
336
			User user = new User();
341
			user.setId(StringUtil.buildUUID());
337
			user.setId(StringUtil.buildUUID());
378
				.getCachedObject(key);
374
				.getCachedObject(key);
379
		if (sc == null) {
375
		if (sc == null) {
380
			this.userDao.delete(con, userId);
376
			this.userDao.delete(con, userId);
381
			throw new JfwBaseException("state码错误!");
377
			throw new JfwBaseException("验证超时");
382
		}
378
		}
383
		if (sc.getExpiredTime() < System.currentTimeMillis()) {
379
		if (sc.getExpiredTime() < System.currentTimeMillis()) {
384
			this.userDao.delete(con, userId);
380
			this.userDao.delete(con, userId);
385
			throw new JfwBaseException("验证超时");
381
			throw new JfwBaseException("验证超时");
386
		}
382
		}
387
		try {
383
		try {
388
			User user = userDao.queryByEmailOrMobilePhone(con, mail);
384
			User user = userDao.queryByEmailOrMobilePhone(con, mail);
504
			throws SQLException {
500
			throws SQLException {
505
		User user = userDao.queryByEmailOrMobilePhone(con, lk);
501
		User user = userDao.queryByEmailOrMobilePhone(con, lk);
506
		if (null == user)
502
		if (null == user)
507
			throw new SQLException("该用户还未注册");
503
			throw new SQLException("该用户还未注册");
508
		if (DEFAULT_PASS_WORD.equals(user.getPasswd()))
504
		if (DEFAULT_PASS_WORD.equals(user.getPasswd()))
509
			return null;
505
			return null;
510
		if (!StringUtil.md5(pw).equals(user.getPasswd()))
506
		if (!StringUtil.md5(pw).equals(user.getPasswd()))
607
			return null;
603
			return null;
608
		user = this.userDao.queryByEmailOrMobilePhone(con, mobilePhone);
604
		user = this.userDao.queryByEmailOrMobilePhone(con, mobilePhone);
609
		if (null != user)
605
		if (null != user)
610
			return "该手机号已经绑定用户";
611
//			throw new JfwBaseException("该手机号已经绑定用户!");
606
			return "该手机号已经绑定其他用户";
612
607
613
		StateCode<String, String> sc = new StateCode<String, String>();
608
		StateCode<String, String> sc = new StateCode<String, String>();
614
609
726
721
727
		User user = this.userDao.queryByEmailOrMobilePhone(con, mobilePhone);
722
		User user = this.userDao.queryByEmailOrMobilePhone(con, mobilePhone);
728
		if (null == user)
723
		if (null == user)
729
			return "该手机号还未注册";
730
//			throw new JfwBaseException("该手机号还未注册!");
724
			return "该手机号还未注册";
731
725
732
		StateCode<String, String> sc = new StateCode<String, String>();
726
		StateCode<String, String> sc = new StateCode<String, String>();
733
		final String key = JfwAppContext.cacheObjectAndGenKey(sc);
727
		final String key = JfwAppContext.cacheObjectAndGenKey(sc);
768
		StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext
762
		StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext
769
				.getCachedObject(state);
763
				.getCachedObject(state);
770
		if (sc == null) {
764
		if (sc == null) {
771
			throw new JfwBaseException("state码错误!");
765
			throw new JfwBaseException("验证超时");
772
		}
766
		}
773
		if (sc.getExpiredTime() < System.currentTimeMillis()) {
767
		if (sc.getExpiredTime() < System.currentTimeMillis()) {
774
			throw new JfwBaseException("验证超时");
768
			throw new JfwBaseException("验证超时");
775
		}
769
		}
776
		return sc.getValue().equals(vc);
770
		return sc.getValue().equals(vc);
777
	}
771
	}
784
		StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext
778
		StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext
785
				.getCachedObject(state);
779
				.getCachedObject(state);
786
		if (sc == null) {
780
		if (sc == null) {
787
			return false;
781
			throw new JfwBaseException("验证超时");
788
		}
782
		}
789
		if (sc.getExpiredTime() < System.currentTimeMillis()) {
783
		if (sc.getExpiredTime() < System.currentTimeMillis()) {
790
			return false;
784
			throw new JfwBaseException("验证超时");
791
		}
785
		}
792
		try {
786
		try {
793
			if (!sc.getKey().equals(mobilePhone) || !sc.getValue().equals(vc))
787
			if (!sc.getKey().equals(mobilePhone) || !sc.getValue().equals(vc))
857
		StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext
851
		StateCode<String, String> sc = (StateCode<String, String>) JfwAppContext
858
				.getCachedObject(state);
852
				.getCachedObject(state);
859
		if (sc == null)
853
		if (sc == null)
860
			return false;
854
			throw new JfwBaseException("验证超时");
861
		if (sc.getExpiredTime() < System.currentTimeMillis())
855
		if (sc.getExpiredTime() < System.currentTimeMillis())
862
			return false;
856
			throw new JfwBaseException("验证超时");
863
		String key = sc.getKey();
857
		String key = sc.getKey();
864
		try {
858
		try {
865
			return this.userDao.updatePassword(con, StringUtil.md5(pw), key) > 0;
859
			return this.userDao.updatePassword(con, StringUtil.md5(pw), key) > 0;