From 7369240c2b60d838e3000d268a19c4f794c5658a Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 19 Jul 2019 09:25:32 +0800 Subject: [PATCH 1/6] =?UTF-8?q?get=5Fuser=5Finfo=E5=8A=A0=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E8=BA=AB=E4=BB=BD=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/get_user_info.json.jbuilder | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/users/get_user_info.json.jbuilder b/app/views/users/get_user_info.json.jbuilder index 779d58e95..fbb9778e2 100644 --- a/app/views/users/get_user_info.json.jbuilder +++ b/app/views/users/get_user_info.json.jbuilder @@ -4,6 +4,7 @@ json.user_id @user.id json.image_url url_to_avatar(@user) json.admin @user.admin? json.is_teacher @user.user_extension&.teacher? +json.user_identity @user.identity json.tidding_count 0 json.user_phone_binded @user.phone.present? if @course From 486ae178a326e7a57e3dbe67835e611500dac5d5 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 19 Jul 2019 10:07:24 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E9=80=89=E7=94=A8=E5=AE=9E=E8=B7=B5?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E7=9A=84=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/subjects_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/subjects_controller.rb b/app/controllers/subjects_controller.rb index b3e317e4b..7857f2ec6 100644 --- a/app/controllers/subjects_controller.rb +++ b/app/controllers/subjects_controller.rb @@ -69,7 +69,8 @@ class SubjectsController < ApplicationController else @subjects = @subjects[offset, limit] subject_ids = @subjects.pluck(:id) - @subjects = Subject.where(id: subject_ids).order("field(id,#{subject_ids.join(',')})").includes(:shixuns, :repertoire) + order_ids = subject_ids.size > 0 ? subject_ids.join(',') : -1 + @subjects = Subject.where(id: subject_ids).order("field(id,#{order_ids})").includes(:shixuns, :repertoire) end end From db3366aaed9000fd723d7eda77e1ec246618d0c3 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 19 Jul 2019 10:15:10 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_commons_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 439da8add..4c3393eaf 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -995,7 +995,8 @@ class HomeworkCommonsController < ApplicationController else @subjects = @subjects[offset, limit] subject_ids = @subjects.pluck(:id) - @subjects = Subject.where(id: subject_ids).order("field(id,#{subject_ids.join(',')})").includes(:shixuns, user: [user_extension: :school]) + order_ids = subject_ids.size > 0 ? subject_ids.join(',') : -1 + @subjects = Subject.where(id: subject_ids).order("field(id,#{order_ids})").includes(:shixuns, user: [user_extension: :school]) end end From bc10b0c43f06f1819fc1ec4893a82cc4ea5a18f3 Mon Sep 17 00:00:00 2001 From: p31729568 Date: Fri, 19 Jul 2019 10:18:50 +0800 Subject: [PATCH 4/6] user must profile compeleted before apply auth --- app/services/users/apply_authentication_service.rb | 2 ++ app/services/users/apply_professional_auth_service.rb | 2 ++ app/views/searchs/index.json.jbuilder | 3 ++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/services/users/apply_authentication_service.rb b/app/services/users/apply_authentication_service.rb index f31bb335c..9e0901ef4 100644 --- a/app/services/users/apply_authentication_service.rb +++ b/app/services/users/apply_authentication_service.rb @@ -9,6 +9,8 @@ class Users::ApplyAuthenticationService < ApplicationService end def call + raise Error, '请先完善基本信息' unless user.profile_completed? + Users::ApplyAuthenticationForm.new(params).validate! raise Error, '您已经申请过实名认证了' if ApplyUserAuthentication.real_name_auth.processing.exists?(user_id: user.id) diff --git a/app/services/users/apply_professional_auth_service.rb b/app/services/users/apply_professional_auth_service.rb index 2d8279317..07afe18ae 100644 --- a/app/services/users/apply_professional_auth_service.rb +++ b/app/services/users/apply_professional_auth_service.rb @@ -9,6 +9,8 @@ class Users::ApplyProfessionalAuthService < ApplicationService end def call + raise Error, '请先完善基本信息' unless user.profile_completed? + Users::ApplyProfessionalAuthForm.new(params).validate! raise Error, '您已经申请过职业认证了' if ApplyUserAuthentication.professional_auth.processing.exists?(user_id: user.id) diff --git a/app/views/searchs/index.json.jbuilder b/app/views/searchs/index.json.jbuilder index a36edb5bd..5fa0c2744 100644 --- a/app/views/searchs/index.json.jbuilder +++ b/app/views/searchs/index.json.jbuilder @@ -5,6 +5,7 @@ json.results do json.type obj.class.name.downcase json.title highlights.delete(:name)&.join('...') || obj.searchable_title - json.description highlights.values[0,5].each { |arr| arr.is_a?(Array) ? arr.join('...') : arr }.join('
') + # json.description highlights.values[0,5].each { |arr| arr.is_a?(Array) ? arr.join('...') : arr }.join('
') + json.content highlights end end \ No newline at end of file From ea31d669d311dbc079fbfe597eab3e88467d7795 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 19 Jul 2019 10:28:11 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E7=99=BB=E5=BD=95=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E5=92=8C=E5=BF=98=E8=AE=B0=E5=AF=86=E7=A0=81=E7=9A=84=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E7=8A=B6=E6=80=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/accounts_controller.rb | 15 +++++++-------- app/models/user.rb | 6 +++--- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 63a38670f..8df358cf7 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -31,10 +31,11 @@ class AccountsController < ApplicationController verifi_code = VerificationCode.where(email: email, code: code, code_type: 8).last end uid_logger("start register: verifi_code is #{verifi_code}, code is #{code}, time is #{Time.now.to_i - verifi_code.try(:created_at).to_i}") - check_code = (verifi_code.try(:code) == code.strip && (Time.now.to_i - verifi_code.created_at.to_i) <= 10*60) - # todo 上线前请删除 - if !check_code && code != "513231" - tip_exception("验证码无效") + # check_code = (verifi_code.try(:code) == code.strip && (Time.now.to_i - verifi_code.created_at.to_i) <= 10*60) + # todo 上线前请删除万能验证码"513231" + if code != "513231" + tip_exception(-2, "验证码不正确") if verifi_code.try(:code) != code.strip + tip_exception(-2, "验证码已失效") if (Time.now.to_i - verifi_code.created_at.to_i) <= 10*60 end code = generate_identifier User, 8 @@ -88,10 +89,8 @@ class AccountsController < ApplicationController verifi_code = VerificationCode.where(email: email, code: code, code_type: 3).last user = User.find_by_mail(email) #这里有问题,应该是为email,而不是mail 6.13-hs end - check_code = (verifi_code.try(:code) == code.strip && (Time.now.to_i - verifi_code.created_at.to_i) <= 10*60) - unless check_code - tip_exception("验证码无效") - end + tip_exception(-2, "验证码不正确") if verifi_code.try(:code) != code.strip + tip_exception(-2, "验证码已失效") if (Time.now.to_i - verifi_code.created_at.to_i) <= 10*60 user.password, user.password_confirmation = params[:new_password], params[:new_password_confirmation] if user.save! diff --git a/app/models/user.rb b/app/models/user.rb index 3ed327c0c..894a28910 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -509,10 +509,10 @@ class User < ApplicationRecord if user # user is already in local database - raise("账号已被注销,请联系管理员") if user.locked? - raise("密码错误") unless user.check_password?(password) + raise Educoder::TipException.new(-2, "违反平台使用规范,账号已被锁定") if user.locked? + raise Educoder::TipException.new(-2, "错误的账号或密码") unless user.check_password?(password) else - raise("账号未注册") + raise Educoder::TipException.new(-2, "错误的账号或密码") end user From 950b8e9acb54a5c9d5f2a355f5f0f65fc41c17c7 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Fri, 19 Jul 2019 10:41:27 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=B3=A8=E5=86=8C=E9=A1=B5=E5=8E=BB?= =?UTF-8?q?=E6=8E=89=E8=B7=AF=E7=94=B1=E7=9A=84=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/accounts_controller.rb | 1 + app/views/accounts/register.json.jbuilder | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 app/views/accounts/register.json.jbuilder diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 8df358cf7..6ac62f887 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -57,6 +57,7 @@ class AccountsController < ApplicationController ) successful_authentication(@user) session[:user_id] = @user.id + normal_status("注册成功") end rescue Exception => e uid_logger_error(e.message) diff --git a/app/views/accounts/register.json.jbuilder b/app/views/accounts/register.json.jbuilder deleted file mode 100644 index 9a3dba175..000000000 --- a/app/views/accounts/register.json.jbuilder +++ /dev/null @@ -1 +0,0 @@ -json.redirect_uri subjects_url \ No newline at end of file