Commit 4342f63f authored by jplang's avatar jplang
Browse files

Add user's API key to /users/current.format (#8529).

git-svn-id: e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 24d02f1e
......@@ -6,6 +6,7 @@ api.user do
api.mail @user.mail if User.current.admin? || !@user.pref.hide_mail
api.created_on @user.created_on
api.last_login_on @user.last_login_on
api.api_key @user.api_key if User.current.admin? || (User.current == @user)
render_api_custom_values @user.visible_custom_field_values, api
......@@ -108,6 +108,18 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
assert_tag 'user', :child => {:tag => 'login', :content => 'jsmith'}
test "GET /users/:id should not return api_key for other user" do
get '/users/3.xml', {}, credentials('jsmith')
assert_response :success
assert_no_tag 'user', :child => {:tag => 'api_key'}
test "GET /users/:id should return api_key for current user" do
get '/users/2.xml', {}, credentials('jsmith')
assert_response :success
assert_tag 'user', :child => {:tag => 'api_key', :content => User.find(2).api_key}
context "POST /users" do
context "with valid parameters" do
setup do
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment