作者 shenhailong

添加 修改登录验证码为 数字加减

@@ -9,6 +9,7 @@ package com.agent.controller.system; @@ -9,6 +9,7 @@ package com.agent.controller.system;
9 9
10 import javax.annotation.Resource; 10 import javax.annotation.Resource;
11 import javax.servlet.http.HttpServletRequest; 11 import javax.servlet.http.HttpServletRequest;
  12 +import javax.servlet.http.HttpSession;
12 13
13 14
14 import com.agent.entity.system.FunctionEntity; 15 import com.agent.entity.system.FunctionEntity;
@@ -152,75 +153,110 @@ public class LoginController { @@ -152,75 +153,110 @@ public class LoginController {
152 @Transactional 153 @Transactional
153 @RequestMapping(value = "/doLogin", method = RequestMethod.POST) 154 @RequestMapping(value = "/doLogin", method = RequestMethod.POST)
154 @ResponseBody 155 @ResponseBody
155 - public ResponseModel doLogin(String loginAccount, String password, String captcha) { 156 + public ResponseModel doLogin(String loginAccount, String password, String captcha, String verifyInput, HttpSession session) {
156 157
157 ResponseModel rm = new ResponseModel(200, "", null); 158 ResponseModel rm = new ResponseModel(200, "", null);
158 // 查询该账号是否被禁用 159 // 查询该账号是否被禁用
159 160
160 - UserEntity userEntity = userService.findLoginaccount(loginAccount);  
161 161
162 - if (userEntity.getStatus() != 0){ 162 + String rand = session.getAttribute("rand").toString();
163 163
164 - rm.setStatus(201);  
165 - return rm;  
166 - }else {  
167 - // 等于5次 锁定账户 admin 除外  
168 - if (userEntity.getLoginerror() != 5){  
169 - SessionUtil.putKey(Constants.CAPTCHA, ""); 164 + UserEntity userEntity = userService.findLoginaccount(loginAccount);
170 165
171 - UserEntity user = new UserEntity();  
172 - user.setLoginaccount(loginAccount);  
173 - user.setPassword(password);  
174 -  
175 - if (!loginAccount.equals("admin") && "true".equals(PropertiesLoader.getLogin("openRemoteLogin"))) {  
176 - // 远程登录  
177 - // 用户数据  
178 - LoginData login = FLogin.login(user);  
179 - // 登录成功!  
180 - if (login.getCode() == 20000) {  
181 - // 往数据库中插入数据  
182 - UserEntity ue = userService.findByLoginaccount(user.getLoginaccount());  
183 - // 用户存在  
184 - if (ue != null) {  
185 - // 修改密码  
186 - userService.updatePassword(ue.getLoginaccount(), MD5Tools.MD5(password)); 166 + if (rand.equals(verifyInput)){
  167 + if (userEntity.getStatus() != 0){
  168 +
  169 + rm.setStatus(201);
  170 + return rm;
  171 + }else {
  172 + // 等于5次 锁定账户 admin 除外
  173 + if (userEntity.getLoginerror() != 5){
  174 + SessionUtil.putKey(Constants.CAPTCHA, "");
  175 +
  176 + UserEntity user = new UserEntity();
  177 + user.setLoginaccount(loginAccount);
  178 + user.setPassword(password);
  179 +
  180 + if (!loginAccount.equals("admin") && "true".equals(PropertiesLoader.getLogin("openRemoteLogin"))) {
  181 + // 远程登录
  182 + // 用户数据
  183 + LoginData login = FLogin.login(user);
  184 + // 登录成功!
  185 + if (login.getCode() == 20000) {
  186 + // 往数据库中插入数据
  187 + UserEntity ue = userService.findByLoginaccount(user.getLoginaccount());
  188 + // 用户存在
  189 + if (ue != null) {
  190 + // 修改密码
  191 + userService.updatePassword(ue.getLoginaccount(), MD5Tools.MD5(password));
  192 + } else {
  193 + // 用户不存在,插入数据
  194 + BasicAgentEntity agent = new BasicAgentEntity();
  195 + agent.setContact(login.getInfodata().getContact());
  196 + agent.setNameCn(login.getInfodata().getCompany());
  197 + agent.setCountryCode("CN");
  198 + agent.setAddress(login.getInfodata().getAddress());
  199 + int agent_id = agentSerive.save2(agent);
  200 +
  201 + ue = new UserEntity();
  202 + ue.setLoginaccount(loginAccount);
  203 + // 设置用户名密码
  204 + ue.setPassword(MD5Tools.MD5(password));
  205 + ue.setRealName(login.getInfodata().getContact());
  206 + ue.setMobile(login.getInfodata().getMobile());
  207 + ue.setStatus(0);
  208 + ue.setAgent(new Long(agent_id));
  209 + RoleEntity re = new RoleEntity();
  210 + re.setId(new Long(1));
  211 + ue.setRole(re);
  212 + // 删除密码
  213 + userService.save(ue);
  214 + }
  215 +
  216 + // 登录用户
  217 + Subject subject = SecurityUtils.getSubject();
  218 + subject.getSession().setAttribute("user", user);
  219 + UsernamePasswordToken token = new UsernamePasswordToken(loginAccount, MD5Tools.MD5(password));
  220 + try {
  221 + subject.login(token);
  222 + subject.getSession().setAttribute("permission", roleService
  223 + .findAllFunctionByRole(((UserEntity) subject.getSession().getAttribute("user")).getRole()));
  224 + subject.getSession().setAttribute("all_function", functionService.findAll());
  225 + //登录成功 请空失败次数
  226 + userService.emptyLoginerror(loginAccount);
  227 + } catch (UnknownAccountException e) {
  228 + rm.setStatus(500);
  229 + rm.setMsg("1");
  230 + } catch (IncorrectCredentialsException e) {
  231 + // 添加错误次数
  232 + userService.updateLoginError(loginAccount, userEntity.getLoginerror() + 1);
  233 + rm.setStatus(500);
  234 + rm.setMsg("1");
  235 + } catch (LockedAccountException e) {
  236 + rm.setStatus(500);
  237 + rm.setMsg("1");
  238 + }
187 } else { 239 } else {
188 - // 用户不存在,插入数据  
189 - BasicAgentEntity agent = new BasicAgentEntity();  
190 - agent.setContact(login.getInfodata().getContact());  
191 - agent.setNameCn(login.getInfodata().getCompany());  
192 - agent.setCountryCode("CN");  
193 - agent.setAddress(login.getInfodata().getAddress());  
194 - int agent_id = agentSerive.save2(agent);  
195 -  
196 - ue = new UserEntity();  
197 - ue.setLoginaccount(loginAccount);  
198 - // 设置用户名密码  
199 - ue.setPassword(MD5Tools.MD5(password));  
200 - ue.setRealName(login.getInfodata().getContact());  
201 - ue.setMobile(login.getInfodata().getMobile());  
202 - ue.setStatus(0);  
203 - ue.setAgent(new Long(agent_id));  
204 - RoleEntity re = new RoleEntity();  
205 - re.setId(new Long(1));  
206 - ue.setRole(re);  
207 - // 删除密码  
208 - userService.save(ue); 240 + rm.setStatus(500);
  241 + rm.setMsg("1");
209 } 242 }
210 - 243 + } else {
211 // 登录用户 244 // 登录用户
212 Subject subject = SecurityUtils.getSubject(); 245 Subject subject = SecurityUtils.getSubject();
213 subject.getSession().setAttribute("user", user); 246 subject.getSession().setAttribute("user", user);
214 UsernamePasswordToken token = new UsernamePasswordToken(loginAccount, MD5Tools.MD5(password)); 247 UsernamePasswordToken token = new UsernamePasswordToken(loginAccount, MD5Tools.MD5(password));
  248 + // System.out.println(loginAccount+" " + password);
215 try { 249 try {
216 subject.login(token); 250 subject.login(token);
217 subject.getSession().setAttribute("permission", roleService 251 subject.getSession().setAttribute("permission", roleService
218 .findAllFunctionByRole(((UserEntity) subject.getSession().getAttribute("user")).getRole())); 252 .findAllFunctionByRole(((UserEntity) subject.getSession().getAttribute("user")).getRole()));
219 subject.getSession().setAttribute("all_function", functionService.findAll()); 253 subject.getSession().setAttribute("all_function", functionService.findAll());
  254 +
220 //登录成功 请空失败次数 255 //登录成功 请空失败次数
221 userService.emptyLoginerror(loginAccount); 256 userService.emptyLoginerror(loginAccount);
222 } catch (UnknownAccountException e) { 257 } catch (UnknownAccountException e) {
223 rm.setStatus(500); 258 rm.setStatus(500);
  259 + System.out.println();
224 rm.setMsg("1"); 260 rm.setMsg("1");
225 } catch (IncorrectCredentialsException e) { 261 } catch (IncorrectCredentialsException e) {
226 // 添加错误次数 262 // 添加错误次数
@@ -231,46 +267,20 @@ public class LoginController { @@ -231,46 +267,20 @@ public class LoginController {
231 rm.setStatus(500); 267 rm.setStatus(500);
232 rm.setMsg("1"); 268 rm.setMsg("1");
233 } 269 }
234 - } else {  
235 - rm.setStatus(500);  
236 - rm.setMsg("1");  
237 - }  
238 - } else {  
239 - // 登录用户  
240 - Subject subject = SecurityUtils.getSubject();  
241 - subject.getSession().setAttribute("user", user);  
242 - UsernamePasswordToken token = new UsernamePasswordToken(loginAccount, MD5Tools.MD5(password));  
243 - // System.out.println(loginAccount+" " + password);  
244 - try {  
245 - subject.login(token);  
246 - subject.getSession().setAttribute("permission", roleService  
247 - .findAllFunctionByRole(((UserEntity) subject.getSession().getAttribute("user")).getRole()));  
248 - subject.getSession().setAttribute("all_function", functionService.findAll());  
249 -  
250 - //登录成功 请空失败次数  
251 - userService.emptyLoginerror(loginAccount);  
252 - } catch (UnknownAccountException e) {  
253 - rm.setStatus(500);  
254 - System.out.println();  
255 - rm.setMsg("1");  
256 - } catch (IncorrectCredentialsException e) {  
257 - // 添加错误次数  
258 - userService.updateLoginError(loginAccount, userEntity.getLoginerror() + 1);  
259 - rm.setStatus(500);  
260 - rm.setMsg("1");  
261 - } catch (LockedAccountException e) {  
262 - rm.setStatus(500);  
263 - rm.setMsg("1");  
264 } 270 }
265 - }  
266 271
267 - return rm;  
268 - }else { 272 + return rm;
  273 + }else {
269 274
270 - userService.updateStatus(loginAccount);  
271 - rm.setStatus(201);  
272 - return rm; 275 + userService.updateStatus(loginAccount);
  276 + rm.setStatus(201);
  277 + return rm;
  278 + }
273 } 279 }
  280 + }else {
  281 +
  282 + rm.setStatus(202);
  283 + return rm;
274 } 284 }
275 } 285 }
276 286
  1 +package com.agent.controller.system;
  2 +
  3 +import com.agent.util.VerifyCodeUtil;
  4 +import org.springframework.web.bind.annotation.RequestMapping;
  5 +import org.springframework.web.bind.annotation.RestController;
  6 +
  7 +import javax.imageio.ImageIO;
  8 +import javax.servlet.ServletException;
  9 +import javax.servlet.ServletOutputStream;
  10 +import javax.servlet.annotation.WebServlet;
  11 +import javax.servlet.http.HttpServlet;
  12 +import javax.servlet.http.HttpServletRequest;
  13 +import javax.servlet.http.HttpServletResponse;
  14 +import java.awt.*;
  15 +import java.awt.image.BufferedImage;
  16 +import java.io.IOException;
  17 +
  18 +@RestController
  19 +public class VerifyCodeController extends HttpServlet{
  20 +
  21 + /**
  22 + * Constructor of the object.
  23 + */
  24 + public VerifyCodeController() {
  25 + super();
  26 + }
  27 +
  28 + public void destroy() {
  29 + super.destroy();
  30 + }
  31 +
  32 +
  33 + @RequestMapping(value = "/getVerifyCode")
  34 + public void doGet(HttpServletRequest request, HttpServletResponse response)
  35 + throws ServletException, IOException {
  36 +
  37 + VerifyCodeUtil verifyCodeUtil = new VerifyCodeUtil();
  38 + try {
  39 + verifyCodeUtil.handleRequestInternal(request, response);
  40 + } catch (Exception e) {
  41 + e.printStackTrace();
  42 + }
  43 +
  44 + }
  45 +
  46 + public void doPost(HttpServletRequest request, HttpServletResponse response)
  47 + throws ServletException, IOException {
  48 + doGet(request,response);
  49 + }
  50 +
  51 + public void init() throws ServletException {
  52 + // Put your code here
  53 + }
  54 +
  55 +
  56 +
  57 +}
@@ -29,7 +29,7 @@ public class MyShiroController implements Filter { @@ -29,7 +29,7 @@ public class MyShiroController implements Filter {
29 } 29 }
30 30
31 private String publicAction[] = { "/login", "/doLogin", "/manifest/app/send", 31 private String publicAction[] = { "/login", "/doLogin", "/manifest/app/send",
32 - "/receipt/a0608c4054662dd902e1314f7e450e3eaa81c114", "/manifest/f5f5669bbdecefd3dacfaba194647c35" }; 32 + "/receipt/a0608c4054662dd902e1314f7e450e3eaa81c114", "/manifest/f5f5669bbdecefd3dacfaba194647c35", "/getVerifyCode" };
33 private String crossDomain[] = { "/cross/", "tracking/detail" }; 33 private String crossDomain[] = { "/cross/", "tracking/detail" };
34 34
35 // manifest/cross/grid.json 35 // manifest/cross/grid.json
  1 +package com.agent.util;
  2 +
  3 +import org.springframework.web.servlet.ModelAndView;
  4 +import org.springframework.web.servlet.mvc.AbstractController;
  5 +
  6 +import javax.imageio.ImageIO;
  7 +import javax.servlet.http.HttpServletRequest;
  8 +import javax.servlet.http.HttpServletResponse;
  9 +import javax.servlet.http.HttpSession;
  10 +import java.awt.*;
  11 +import java.awt.image.BufferedImage;
  12 +import java.util.Random;
  13 +
  14 +public class VerifyCodeUtil extends AbstractController{
  15 +
  16 +
  17 + @Override
  18 + public ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
  19 +
  20 + try {
  21 +
  22 + response.setContentType("image/jpeg");
  23 + response.setHeader("Pragma", "No-cache");
  24 + response.setHeader("Cache-Control", "no-cache");
  25 + response.setDateHeader("Expires", 0);
  26 + // 在内存中创建图象
  27 + int width = 59, height = 20;
  28 + BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
  29 +
  30 + // 获取图形上下文
  31 + Graphics g = image.getGraphics();
  32 + // 生成随机类
  33 + Random random = new Random();
  34 + // 设定背景色
  35 + g.setColor(getRandColor(200, 250));
  36 + g.fillRect(0, 0, width, height);
  37 + // 设定字体
  38 + g.setFont(new Font("Arial", Font.PLAIN, 18));
  39 + // 随机产生155条干扰线,使图象中的认证码不易被其它程序探测到
  40 + g.setColor(getRandColor(160, 200));
  41 + for (int i = 0; i < 155; i++) {
  42 + int x = random.nextInt(width);
  43 + int y = random.nextInt(height);
  44 + int xl = random.nextInt(12);
  45 + int yl = random.nextInt(12);
  46 + g.drawLine(x, y, x + xl, y + yl);
  47 + }
  48 + // 取随机产生的认证码(4位数字)
  49 + int sRand = 0;
  50 + // 是加法还是减法
  51 + int math = random.nextInt(2);
  52 + // 加法
  53 + if (math == 0) {
  54 + // 第一个数据
  55 + int rand = random.nextInt(10);
  56 + if (rand == 0) {
  57 + rand = 1;
  58 + }
  59 + g.setColor(new Color(20 + random.nextInt(110), 20 + random.nextInt(110), 20 + random.nextInt(110)));// 调用函数出来的颜色相同,可能是因为种子太接近,所以只能直接生成
  60 + g.drawString("" + rand, 13 * 0 + 6, 16);
  61 + //
  62 + int rand1 = random.nextInt(10);
  63 + g.setColor(new Color(20 + random.nextInt(110), 20 + random.nextInt(110), 20 + random.nextInt(110)));// 调用函数出来的颜色相同,可能是因为种子太接近,所以只能直接生成
  64 + g.drawString("" + rand1, 13 * 1 + 6, 16);
  65 + // +号
  66 + g.setColor(new Color(20 + random.nextInt(110), 20 + random.nextInt(110), 20 + random.nextInt(110)));// 调用函数出来的颜色相同,可能是因为种子太接近,所以只能直接生成
  67 + g.drawString("+", 13 * 2 + 6, 16);
  68 + // 第二个数据
  69 + int rand2 = random.nextInt(10);
  70 + g.setColor(new Color(20 + random.nextInt(110), 20 + random.nextInt(110), 20 + random.nextInt(110)));// 调用函数出来的颜色相同,可能是因为种子太接近,所以只能直接生成
  71 + g.drawString("" + rand2, 13 * 3 + 6, 16);
  72 + sRand = rand * 10 + rand1 + rand2;
  73 + } else {
  74 + // 减法
  75 + // 第一个数据
  76 + int rand = random.nextInt(10);
  77 + if (rand == 0) {
  78 + rand = 1;
  79 + }
  80 + g.setColor(new Color(20 + random.nextInt(110), 20 + random.nextInt(110), 20 + random.nextInt(110)));// 调用函数出来的颜色相同,可能是因为种子太接近,所以只能直接生成
  81 + g.drawString("" + rand, 13 * 0 + 6, 16);
  82 + //
  83 + int rand1 = random.nextInt(10);
  84 + g.setColor(new Color(20 + random.nextInt(110), 20 + random.nextInt(110), 20 + random.nextInt(110)));// 调用函数出来的颜色相同,可能是因为种子太接近,所以只能直接生成
  85 + g.drawString("" + rand1, 13 * 1 + 6, 16);
  86 + // -号
  87 + g.setColor(new Color(20 + random.nextInt(110), 20 + random.nextInt(110), 20 + random.nextInt(110)));// 调用函数出来的颜色相同,可能是因为种子太接近,所以只能直接生成
  88 + g.drawString("-", 13 * 2 + 6 + 3, 16);
  89 + // 第二个数据
  90 + int rand2 = random.nextInt(10);
  91 + g.setColor(new Color(20 + random.nextInt(110), 20 + random.nextInt(110), 20 + random.nextInt(110)));// 调用函数出来的颜色相同,可能是因为种子太接近,所以只能直接生成
  92 + g.drawString("" + rand2, 13 * 3 + 6, 16);
  93 + sRand = rand * 10 + rand1 - rand2;
  94 + }
  95 + synchronized (this) {
  96 + HttpSession session = request.getSession();
  97 + session.setAttribute("rand", "" + sRand);
  98 + System.out.println(sRand);
  99 + }
  100 + ImageIO.write(image, "jpg", response.getOutputStream());
  101 +
  102 + } catch (Exception e) {
  103 + // logger.error(e.getLocalizedMessage(), e.fillInStackTrace());
  104 + }
  105 + return null;
  106 + }
  107 +
  108 +
  109 + /*
  110 + * 获得颜色
  111 + */
  112 + private Color getRandColor(int fc, int bc) {
  113 +
  114 + Random random = new Random();
  115 +
  116 + if (fc > 255)
  117 + fc = 255;
  118 + if (bc > 255)
  119 + bc = 255;
  120 + int r = fc + random.nextInt(bc - fc - 16);//110+7
  121 + int g = fc + random.nextInt(bc - fc - 14);//110+9
  122 + int b = fc + random.nextInt(bc - fc - 18);//110+5
  123 + return new Color(r, g, b);
  124 + }
  125 +
  126 +}
@@ -20,12 +20,18 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request. @@ -20,12 +20,18 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.
20 <div style="font-size:16px;color:white;margin-left:510px;">&nbsp;郑州机场航空物流信息平台</div> 20 <div style="font-size:16px;color:white;margin-left:510px;">&nbsp;郑州机场航空物流信息平台</div>
21 </div> 21 </div>
22 <div class="login_box"> 22 <div class="login_box">
23 - <input class="admin" type="text" placeholder="请输入账号" id="userName" maxlength="30" />  
24 - <input class="passWord" type="password" placeholder="请输入密码" id="password" onblur="regularValue()" maxlength="30" /> 23 + <div>
  24 + <input class="admin" type="text" placeholder="请输入账号" id="userName" maxlength="30" />
  25 + <input class="passWord" style="margin-bottom: 10px" type="password" placeholder="请输入密码" id="password" onblur="regularValue()" maxlength="30" /><span id="showStrength"></span>
  26 + </div>
25 27
26 28
27 - <%--<input type="text" name="valida" id="valida" οnkeydοwn="doEnter();">--%>  
28 - <%--<span><img src="<%=basePath %>verify/code" id="imgValida" οnclick="this.src='<%=basePath %>verify/code?a='+Math.random()" class="imgValida"></span>--%> 29 + <div style="margin-top: 10px;">
  30 + <input class="verifyInputs" style="float: left; width: 191px; height: 26px; line-height: 35px; margin-left: 0px; padding: 5px;" name="verifyInput" id="verifyInput" placeholder="请输入验证码">
  31 +
  32 + <img class="verifyCodes" style="float: left; width: 202px; height: 37px; line-height: 35px; margin-left: 11px; padding: 5px; margin-top: -5px;" onclick="changeCode()" src="getVerifyCode">
  33 +
  34 + </div>
29 35
30 <input class="submit" type="button" onclick="doLogin()"/> 36 <input class="submit" type="button" onclick="doLogin()"/>
31 37
@@ -62,6 +68,7 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request. @@ -62,6 +68,7 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.
62 function doLogin(){ 68 function doLogin(){
63 var userName = $("#userName").val(); 69 var userName = $("#userName").val();
64 var password = $("#password").val(); 70 var password = $("#password").val();
  71 + var verifyInput = $("#verifyInput").val();
65 72
66 if(userName==''){ 73 if(userName==''){
67 $("#userName").focus(); 74 $("#userName").focus();
@@ -78,13 +85,19 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request. @@ -78,13 +85,19 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.
78 }); 85 });
79 return false; 86 return false;
80 }else{ 87 }else{
81 - jQuery.post("<%=basePath %>doLogin",{loginAccount:userName,password:password},function(result){ 88 + jQuery.post("<%=basePath %>doLogin",{loginAccount:userName, password:password, verifyInput:verifyInput},function(result){
82 89
83 if (result.status == 201){ 90 if (result.status == 201){
84 $("#userName").focus(); 91 $("#userName").focus();
85 layer.tips('用户名已被禁用请联系管理员', '#userName', { 92 layer.tips('用户名已被禁用请联系管理员', '#userName', {
86 tips: [1, '#0FA6D8'] //还可配置颜色 93 tips: [1, '#0FA6D8'] //还可配置颜色
87 }); 94 });
  95 + } else if(result.status == 202){
  96 +
  97 + $("#verifyInput").focus();
  98 + layer.tips('验证码错误', '#verifyInput', {
  99 + tips: [1, '#0FA6D8'] //还可配置颜色
  100 + });
88 } else{ 101 } else{
89 if(result.status == 200){ 102 if(result.status == 200){
90 sessionStorage.removeItem("menuid"); 103 sessionStorage.removeItem("menuid");
@@ -116,22 +129,33 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request. @@ -116,22 +129,33 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.
116 } 129 }
117 130
118 function regularValue() { 131 function regularValue() {
119 - var passwords = $("#newpassword").val(); 132 + var passwords = $("#password").val();
120 133
121 var reg = /^(?![A-Za-z0-9]+$)(?![a-z0-9\W]+$)(?![A-Za-z\W]+$)(?![A-Z0-9\W]+$)[a-zA-Z0-9\W]{8,}$/; 134 var reg = /^(?![A-Za-z0-9]+$)(?![a-z0-9\W]+$)(?![A-Za-z\W]+$)(?![A-Z0-9\W]+$)[a-zA-Z0-9\W]{8,}$/;
122 135
123 var re = new RegExp(reg); 136 var re = new RegExp(reg);
124 137
125 if (re.test(passwords)){ 138 if (re.test(passwords)){
  139 + //符合规则  
  140 +// showStrength.innerHTML = "".fontcolor("green");
  141 +// document.getElementById("password").className = "icon ticker";
126 return true; 142 return true;
127 }else { 143 }else {
128 //不符合规则   144 //不符合规则  
129 - layer.tips('您的密码过于简单请及时修改', '#userName', { 145 + layer.tips('您的密码过于简单,请及时修改', '#password', {
130 tips: [1, '#0FA6D8'] //还可配置颜色 146 tips: [1, '#0FA6D8'] //还可配置颜色
131 }); 147 });
132 return false; 148 return false;
133 } 149 }
134 } 150 }
  151 +
  152 +
  153 + function changeCode() {
  154 +
  155 + var src = " getVerifyCode?"+new Date().getTime(); //加时间戳,防止浏览器利用缓存
  156 +
  157 + $('.verifyCodes').attr("src",src);
  158 + }
135 159
136 </script> 160 </script>
137 </html> 161 </html>
@@ -62,6 +62,8 @@ div,form,img,ul,li,input,p,ul,ol,li,form{margin:0px;padding:0px;border:0px; list @@ -62,6 +62,8 @@ div,form,img,ul,li,input,p,ul,ol,li,form{margin:0px;padding:0px;border:0px; list
62 /*border-radius: 5px; 62 /*border-radius: 5px;
63 behavior: url(css/ie-css3.htc);*/ 63 behavior: url(css/ie-css3.htc);*/
64 } 64 }
  65 +
  66 +
65 #login .login_box .passWord{ 67 #login .login_box .passWord{
66 float: left; 68 float: left;
67 width: 167px; 69 width: 167px;
@@ -70,9 +72,14 @@ div,form,img,ul,li,input,p,ul,ol,li,form{margin:0px;padding:0px;border:0px; list @@ -70,9 +72,14 @@ div,form,img,ul,li,input,p,ul,ol,li,form{margin:0px;padding:0px;border:0px; list
70 margin-left: 15px; 72 margin-left: 15px;
71 background: url(../img/icon_password.jpg) no-repeat 10px center #FFFFFF; 73 background: url(../img/icon_password.jpg) no-repeat 10px center #FFFFFF;
72 padding-left: 35px; 74 padding-left: 35px;
  75 +
73 /*border-radius: 5px; 76 /*border-radius: 5px;
74 behavior: url(css/ie-css3.htc);*/ 77 behavior: url(css/ie-css3.htc);*/
75 } 78 }
  79 +
  80 +
  81 +
  82 +
76 #login .login_box .submit{ 83 #login .login_box .submit{
77 float: left; 84 float: left;
78 margin-left: 15px; 85 margin-left: 15px;