Browse Source

Merge branch 'pre_trustie_server' into trustie_server

pull/330/head
yystopf 3 years ago
parent
commit
f0b3a54837
3 changed files with 15 additions and 10 deletions
  1. +1
    -1
      app/controllers/api/v1/project_topics_controller.rb
  2. +7
    -8
      app/controllers/api/v1/users_controller.rb
  3. +7
    -1
      config/routes/api.rb

+ 1
- 1
app/controllers/api/v1/project_topics_controller.rb View File

@@ -3,7 +3,7 @@ class Api::V1::ProjectTopicsController < Api::V1::BaseController
def index
@project_topics = ProjectTopic
@project_topics = @project_topics.ransack(name_cont: params[:keyword]) if params[:keyword].present?
@project_topics = @project_topics.includes(:projects)
# @project_topics = @project_topics.includes(:projects)
@project_topics = kaminary_select_paginate(@project_topics)
end



+ 7
- 8
app/controllers/api/v1/users_controller.rb View File

@@ -1,7 +1,12 @@
class Api::V1::UsersController < Api::V1::BaseController

before_action :load_observe_user
before_action :check_auth_for_observe_user
before_action :load_observe_user, except: [:check_user_id]
before_action :check_auth_for_observe_user, except: [:check_user_id]

def check_user_id
return tip_exception(-1, "用户ID不存在") unless params[:user_id].present? && User.exists?(id: params[:user_id])
render_ok
end

def send_email_vefify_code
code = %W(0 1 2 3 4 5 6 7 8 9)
@@ -42,12 +47,6 @@ 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


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

@@ -1,11 +1,17 @@
defaults format: :json do
namespace :api do
namespace :v1 do

resources :users, only: [:index] do
collection do
post :check_user_id
end
end

scope ':owner' 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