forked from Gitlink/forgeplus
定制用户查询接口
This commit is contained in:
parent
93ad4b046b
commit
7767f4b262
|
@ -702,6 +702,15 @@ class UsersController < ApplicationController
|
||||||
@user = User.find_by(mail: params[:email])
|
@user = User.find_by(mail: params[:email])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#根据login获取用户信息
|
||||||
|
def get_user_info_by_login
|
||||||
|
private_token = "hriEn3UwXfJs3PmyXnSH"
|
||||||
|
sign = Digest::MD5.hexdigest("#{private_token}:#{params[:login]}")
|
||||||
|
tip_exception(401, '401 Unauthorized') unless params[:sign].to_s == sign
|
||||||
|
user = User.find_by_login params[:login]
|
||||||
|
render_ok(data: {username: user.real_name, school: user.custom_department, login: user.login, phone: user.phone, mail: user.mail})
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def load_user
|
def load_user
|
||||||
@user = User.find_by_login(params[:id]) || User.find_by(id: params[:id])
|
@user = User.find_by_login(params[:id]) || User.find_by(id: params[:id])
|
||||||
|
@ -731,7 +740,7 @@ class UsersController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def sso_login
|
def sso_login
|
||||||
if params[:login].present? && !current_user.logged? && params[:websiteName].present?
|
if params[:login].present? && !current_user.logged? && params[:websiteName].present? && request.referer.to_s.include?("gitlink.org.cn")
|
||||||
user = User.where("login = ?", "#{params[:login].presence}").first
|
user = User.where("login = ?", "#{params[:login].presence}").first
|
||||||
# 已同步注册,直接登录
|
# 已同步注册,直接登录
|
||||||
if user.present?
|
if user.present?
|
||||||
|
|
|
@ -288,6 +288,7 @@ Rails.application.routes.draw do
|
||||||
post :following
|
post :following
|
||||||
post :unfollow
|
post :unfollow
|
||||||
get :get_user_info
|
get :get_user_info
|
||||||
|
get :get_user_info_by_login
|
||||||
get :attachment_show
|
get :attachment_show
|
||||||
get :html_show
|
get :html_show
|
||||||
get :get_navigation_info
|
get :get_navigation_info
|
||||||
|
|
Loading…
Reference in New Issue