forked from Gitlink/forgeplus
add: get user image action
This commit is contained in:
parent
8f5bb0e2d9
commit
fc3cf01d3f
|
@ -97,6 +97,13 @@ class UsersController < ApplicationController
|
|||
render_error(-1, '头像修改失败!')
|
||||
end
|
||||
|
||||
def get_image
|
||||
return render_not_found unless @user = User.find_by(login: params[:id]) || User.find_by_id(params[:id])
|
||||
return render_forbidden unless User.current.logged? && (current_user&.admin? || current_user.id == @user.id)
|
||||
|
||||
redirect_to Rails.application.config_for(:configuration)['platform_url'] + "/" + url_to_avatar(@user).to_s
|
||||
end
|
||||
|
||||
def me
|
||||
@user = current_user
|
||||
end
|
||||
|
|
|
@ -147,6 +147,15 @@ module ApplicationHelper
|
|||
end
|
||||
end
|
||||
|
||||
def url_to_avatar_with_platform_url(source)
|
||||
platform_url = Rails.application.config_for(:configuration)['platform_url']
|
||||
if platform_url
|
||||
return Rails.application.config_for(:configuration)['platform_url'] + "/" + url_to_avatar(source).to_s
|
||||
else
|
||||
return url_to_avatar(source).to_s
|
||||
end
|
||||
end
|
||||
|
||||
# 主页banner图
|
||||
def banner_img(source_type)
|
||||
if File.exist?(disk_filename(source_type, "banner"))
|
||||
|
|
|
@ -22,4 +22,4 @@ json.city @user.city
|
|||
json.custom_department @user.custom_department
|
||||
json.description @user.description
|
||||
json.(@user, :show_email, :show_department, :show_location)
|
||||
json.message_unread_total @message_unread_total
|
||||
json.message_unread_total @message_unread_total
|
||||
|
|
|
@ -214,6 +214,7 @@ Rails.application.routes.draw do
|
|||
get :fan_users
|
||||
get :hovercard
|
||||
put :update_image
|
||||
get :get_image
|
||||
end
|
||||
collection do
|
||||
post :following
|
||||
|
|
Loading…
Reference in New Issue