mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-02 19:30:48 +08:00
新增: 根据邮箱来获取用户
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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])
|
||||
|
||||
1
app/views/users/email_search.json.jbuilder
Normal file
1
app/views/users/email_search.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.partial! 'users/user', locals: { user: @user }
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user