新增: 根据邮箱来获取用户

This commit is contained in:
yystopf 2022-05-24 17:26:10 +08:00
parent 5cf257c3cc
commit 8e8ec821f2
4 changed files with 9 additions and 1 deletions

View File

@ -3,7 +3,7 @@ module RenderHelper
render json: { status: 0, message: 'success' }.merge(data)
end
def render_error(status = -1, message = '')
def render_error(message = '', status=-1)
render json: { status: status, message: message }
end

View File

@ -301,6 +301,12 @@ class UsersController < ApplicationController
end
end
def email_search
return render_error('请输入email') if params[:email].blank?
@user = User.find_by(mail: params[:email])
return render_not_found unless @user.present?
end
private
def load_user
@user = User.find_by_login(params[:id]) || User.find_by(id: params[:id])

View File

@ -0,0 +1 @@
json.partial! 'users/user', locals: { user: @user }

View File

@ -237,6 +237,7 @@ Rails.application.routes.draw do
get :trustie_projects
get :trustie_related_projects
post :sync_user_info
get :email_search
scope '/ci', module: :ci do
scope do