From 6b343140e564c164d5eb3afb4f8873be8bfe1d8c Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 9 Dec 2019 18:14:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E5=AF=86=E7=A0=81=E7=9A=84?= =?UTF-8?q?=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/accounts_controller.rb | 4 ++-- app/libs/custom_regexp.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 592d84fab..23240fa75 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -38,7 +38,7 @@ class AccountsController < ApplicationController return normal_status(-2, "验证码已失效") if !verifi_code&.effective? end - return normal_status(-1, "8~16位密码,支持字母数字和符号") if !params[:password] =~ CustomRegexp::PASSWORD + return normal_status(-1, "8~16位密码,支持字母数字和符号") unless params[:password] =~ CustomRegexp::PASSWORD code = generate_identifier User, 8, pre login = pre + code @@ -116,7 +116,7 @@ class AccountsController < ApplicationController end return normal_status(-2, "验证码不正确") if verifi_code.try(:code) != code.strip return normal_status(-2, "验证码已失效") if !verifi_code&.effective? - return normal_status(-1, "8~16位密码,支持字母数字和符号") if !params[:new_password] =~ CustomRegexp::PASSWORD + return normal_status(-1, "8~16位密码,支持字母数字和符号") unless params[:new_password] =~ CustomRegexp::PASSWORD user.password, user.password_confirmation = params[:new_password], params[:new_password_confirmation] ActiveRecord::Base.transaction do diff --git a/app/libs/custom_regexp.rb b/app/libs/custom_regexp.rb index dd2ebb0b8..2980f2ed2 100644 --- a/app/libs/custom_regexp.rb +++ b/app/libs/custom_regexp.rb @@ -3,5 +3,5 @@ module CustomRegexp EMAIL = /\A[a-zA-Z0-9]+([._\\]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+\z/ LASTNAME = /\A[a-zA-Z0-9\u4e00-\u9fa5]+\z/ NICKNAME = /\A[\u4e00-\u9fa5_a-zA-Z0-9]+\z/ - PASSWORD = /\A[a-z_A-Z0-9-\.!@#\$%\\\^&\*\)\(\+=\{\}\[\]\/",'<>~\·`\?:;|]{8,16}\z/ + PASSWORD = /\A[a-z_A-Z0-9\-\.!@#\$%\\\^&\*\)\(\+=\{\}\[\]\/",'_<>~\·`\?:;|]{8,16}\z/ end \ No newline at end of file