From a38ebeaca2c8c7348e4566bd05fa34c4a72ecc54 Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 19 Apr 2023 16:45:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E7=94=A8=E6=88=B7id=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/api/v1/users_controller.rb | 6 ++++++ config/routes/api.rb | 1 + 2 files changed, 7 insertions(+) diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index a37db2524..807efd5f3 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -42,6 +42,12 @@ class Api::V1::UsersController < Api::V1::BaseController end end + def check_user_id + id = params[:user_id] + return tip_exception(-1, "用户ID不存在") unless User.exists?(id: id) + render_ok + end + def check_password password = params[:password] return tip_exception(-5, "8~16位密码,支持字母数字和符号") unless password =~ CustomRegexp::PASSWORD diff --git a/config/routes/api.rb b/config/routes/api.rb index 62d49caf2..92b5868f5 100644 --- a/config/routes/api.rb +++ b/config/routes/api.rb @@ -5,6 +5,7 @@ defaults format: :json do resource :users, path: '/', only: [:update, :edit, :destroy] do collection do get :send_email_vefify_code + post :check_user_id post :check_password post :check_email post :check_email_verify_code