mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-02-16 03:30:05 -05:00
Allow periods in the external_id value used in the /users/by-external route.
This commit is contained in:
parent
f15b0d205f
commit
1f0915bf83
2 changed files with 9 additions and 1 deletions
|
@ -28,6 +28,13 @@ class UsersController < ApplicationController
|
|||
def show
|
||||
@user = fetch_user_from_params
|
||||
user_serializer = UserSerializer.new(@user, scope: guardian, root: 'user')
|
||||
|
||||
# This is a hack to get around a Rails issue where values with periods aren't handled correctly
|
||||
# when used as part of a route.
|
||||
if params[:external_id] and params[:external_id].ends_with? '.json'
|
||||
return render_json_dump(user_serializer)
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
@restrict_fields = guardian.restrict_user_fields?(@user)
|
||||
|
|
|
@ -256,7 +256,8 @@ Discourse::Application.routes.draw do
|
|||
get "users/:username/badges" => "users#show", constraints: {username: USERNAME_ROUTE_FORMAT}
|
||||
get "users/:username/notifications" => "users#show", constraints: {username: USERNAME_ROUTE_FORMAT}
|
||||
delete "users/:username" => "users#destroy", constraints: {username: USERNAME_ROUTE_FORMAT}
|
||||
get "users/by-external/:external_id" => "users#show"
|
||||
# The external_id constraint is to allow periods to be used in the value without becoming part of the format. ie: foo.bar.json
|
||||
get "users/by-external/:external_id" => "users#show", constraints: {external_id: /[^\/]+/}
|
||||
get "users/:username/flagged-posts" => "users#show", constraints: {username: USERNAME_ROUTE_FORMAT}
|
||||
get "users/:username/deleted-posts" => "users#show", constraints: {username: USERNAME_ROUTE_FORMAT}
|
||||
get "users/:username/badges_json" => "user_badges#username"
|
||||
|
|
Loading…
Reference in a new issue