mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
Expose the Admin flag on the users api to admin users (#29459).
Patch by Holger Just. git-svn-id: http://svn.redmine.org/redmine/trunk@17496 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
e9d15d691b
commit
0d29d3208d
@ -3,6 +3,7 @@ api.array :users, api_meta(:total_count => @user_count, :offset => @offset, :lim
|
|||||||
api.user do
|
api.user do
|
||||||
api.id user.id
|
api.id user.id
|
||||||
api.login user.login
|
api.login user.login
|
||||||
|
api.admin user.admin?
|
||||||
api.firstname user.firstname
|
api.firstname user.firstname
|
||||||
api.lastname user.lastname
|
api.lastname user.lastname
|
||||||
api.mail user.mail
|
api.mail user.mail
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
api.user do
|
api.user do
|
||||||
api.id @user.id
|
api.id @user.id
|
||||||
api.login @user.login if User.current.admin? || (User.current == @user)
|
api.login @user.login if User.current.admin? || (User.current == @user)
|
||||||
|
api.admin @user.admin? if User.current.admin? || (User.current == @user)
|
||||||
api.firstname @user.firstname
|
api.firstname @user.firstname
|
||||||
api.lastname @user.lastname
|
api.lastname @user.lastname
|
||||||
api.mail @user.mail if User.current.admin? || !@user.pref.hide_mail
|
api.mail @user.mail if User.current.admin? || !@user.pref.hide_mail
|
||||||
|
|||||||
@ -125,6 +125,18 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
|
|||||||
assert_select 'user status', :text => User.find(1).status.to_s
|
assert_select 'user status', :text => User.find(1).status.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "GET /users/:id should return admin status for current user" do
|
||||||
|
get '/users/2.xml', :headers => credentials('jsmith')
|
||||||
|
assert_response :success
|
||||||
|
assert_select 'user admin', :text => 'false'
|
||||||
|
end
|
||||||
|
|
||||||
|
test "GET /users/:id should not return admin status for other user" do
|
||||||
|
get '/users/3.xml', :headers => credentials('jsmith')
|
||||||
|
assert_response :success
|
||||||
|
assert_select 'user admin', 0
|
||||||
|
end
|
||||||
|
|
||||||
test "POST /users.xml with valid parameters should create the user" do
|
test "POST /users.xml with valid parameters should create the user" do
|
||||||
assert_difference('User.count') do
|
assert_difference('User.count') do
|
||||||
post '/users.xml',
|
post '/users.xml',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user