Browse Source

新增:检查用户id的接口

pull/343/head
yystopf 3 years ago
parent
commit
a38ebeaca2
2 changed files with 7 additions and 0 deletions
  1. +6
    -0
      app/controllers/api/v1/users_controller.rb
  2. +1
    -0
      config/routes/api.rb

+ 6
- 0
app/controllers/api/v1/users_controller.rb View File

@@ -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


+ 1
- 0
config/routes/api.rb View File

@@ -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


Loading…
Cancel
Save