diff options
author | Go MAEDA <maeda@farend.jp> | 2019-06-16 09:34:49 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2019-06-16 09:34:49 +0000 |
commit | 9cdd8bf039c78017ff80283ef76c2f45783ec987 (patch) | |
tree | ea157e585970ed801b7340fd4e8432c9912c6c76 /app | |
parent | d16e36028fa635d736b8fc04b53408aab766d9eb (diff) | |
download | redmine-9cdd8bf039c78017ff80283ef76c2f45783ec987.tar.gz redmine-9cdd8bf039c78017ff80283ef76c2f45783ec987.zip |
Enables API access to /my/account for updating user account data (#31399).
Patch by Jens Krämer.
git-svn-id: http://svn.redmine.org/redmine/trunk@18257 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/my_controller.rb | 20 | ||||
-rw-r--r-- | app/views/my/account.api.rsb | 13 | ||||
-rw-r--r-- | app/views/my/account.html.erb | 2 |
3 files changed, 30 insertions, 5 deletions
diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index 58763f0c3..606fd5cb3 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -23,7 +23,9 @@ class MyController < ApplicationController # let user change user's password when user has to skip_before_action :check_password_change, :only => :password - require_sudo_mode :account, only: :post + accept_api_auth :account + + require_sudo_mode :account, only: :put require_sudo_mode :reset_rss_key, :reset_api_key, :show_api_key, :destroy helper :issues @@ -49,15 +51,25 @@ class MyController < ApplicationController def account @user = User.current @pref = @user.pref - if request.post? + if request.put? @user.safe_attributes = params[:user] @user.pref.safe_attributes = params[:pref] if @user.save @user.pref.save set_language_if_valid @user.language - flash[:notice] = l(:notice_account_updated) - redirect_to my_account_path + respond_to do |format| + format.html { + flash[:notice] = l(:notice_account_updated) + redirect_to my_account_path + } + format.api { render_api_ok } + end return + else + respond_to do |format| + format.html { render :action => :account } + format.api { render_validation_errors(@user) } + end end end end diff --git a/app/views/my/account.api.rsb b/app/views/my/account.api.rsb new file mode 100644 index 000000000..c1cac2bbe --- /dev/null +++ b/app/views/my/account.api.rsb @@ -0,0 +1,13 @@ +api.user do + api.id @user.id + api.login @user.login + api.admin @user.admin? + api.firstname @user.firstname + api.lastname @user.lastname + api.mail @user.mail + api.created_on @user.created_on + api.last_login_on @user.last_login_on + api.api_key @user.api_key + + render_api_custom_values @user.visible_custom_field_values, api +end diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index 63402c977..87b2d7cbd 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -14,7 +14,7 @@ <%= labelled_form_for :user, @user, :url => { :action => "account" }, :html => { :id => 'my_account_form', - :method => :post, :multipart => true } do |f| %> + :method => :put, :multipart => true } do |f| %> <div class="splitcontent"> <div class="splitcontentleft"> <fieldset class="box tabular"> |