From 892aa31ea9c4226a6cf878ca1be7f52d07eb0dbe Mon Sep 17 00:00:00 2001 From: chenjing <28122123@qq.com> Date: Mon, 25 Sep 2023 11:29:44 +0800 Subject: [PATCH] check keywords --- app/controllers/accounts_controller.rb | 6 ++++++ config/routes.rb | 1 + 2 files changed, 7 insertions(+) diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index 320ca05e2..b6ac9987d 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -359,6 +359,12 @@ class AccountsController < ApplicationController Register::LoginCheckColumnsForm.new(check_params.merge(user: current_user)).validate! render_ok end + + def check_keywords + text = params[:text]&.gsub(/\s+/, "") + tip_exception("无法使用以下关键词:#{text},请重新命名") if ReversedKeyword.check_exists?(text) + render_ok + end private diff --git a/config/routes.rb b/config/routes.rb index 7b6c4d8bc..cc10bd987 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -261,6 +261,7 @@ Rails.application.routes.draw do post :remote_password post :change_password post :check + post :check_keywords post :login_check post :simple_update end