summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorEric Davis <edavis@littlestreamsoftware.com>2010-09-28 15:28:50 +0000
committerEric Davis <edavis@littlestreamsoftware.com>2010-09-28 15:28:50 +0000
commit3a3263102a7cda4be1c90168a9d32fa904d58272 (patch)
treebcd4ec938b2109caba6238d9bdc426c9ae335f5f /app
parent79e30e7087d714ad81de83d389c37ae7d46d4dad (diff)
downloadredmine-3a3263102a7cda4be1c90168a9d32fa904d58272.tar.gz
redmine-3a3263102a7cda4be1c90168a9d32fa904d58272.zip
Refactor: split UsersController#add into #add and #create
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4215 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/controllers/users_controller.rb32
-rw-r--r--app/views/users/add.rhtml2
2 files changed, 19 insertions, 15 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index b854850a3..f22427a66 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -72,22 +72,26 @@ class UsersController < ApplicationController
end
def add
- if request.get?
- @user = User.new(:language => Setting.default_language)
+ @user = User.new(:language => Setting.default_language)
+ @auth_sources = AuthSource.find(:all)
+ end
+
+ verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
+ def create
+ @user = User.new(params[:user])
+ @user.admin = params[:user][:admin] || false
+ @user.login = params[:user][:login]
+ @user.password, @user.password_confirmation = params[:password], params[:password_confirmation] unless @user.auth_source_id
+ if @user.save
+ Mailer.deliver_account_information(@user, params[:password]) if params[:send_information]
+ flash[:notice] = l(:notice_successful_create)
+ redirect_to(params[:continue] ? {:controller => 'users', :action => 'add'} :
+ {:controller => 'users', :action => 'edit', :id => @user})
+ return
else
- @user = User.new(params[:user])
- @user.admin = params[:user][:admin] || false
- @user.login = params[:user][:login]
- @user.password, @user.password_confirmation = params[:password], params[:password_confirmation] unless @user.auth_source_id
- if @user.save
- Mailer.deliver_account_information(@user, params[:password]) if params[:send_information]
- flash[:notice] = l(:notice_successful_create)
- redirect_to(params[:continue] ? {:controller => 'users', :action => 'add'} :
- {:controller => 'users', :action => 'edit', :id => @user})
- return
- end
+ @auth_sources = AuthSource.find(:all)
+ render :action => 'add'
end
- @auth_sources = AuthSource.find(:all)
end
def edit
diff --git a/app/views/users/add.rhtml b/app/views/users/add.rhtml
index 2e0743e87..0e7a33319 100644
--- a/app/views/users/add.rhtml
+++ b/app/views/users/add.rhtml
@@ -1,6 +1,6 @@
<h2><%= link_to l(:label_user_plural), :controller => 'users', :action => 'index' %> &#187; <%=l(:label_user_new)%></h2>
-<% labelled_tabular_form_for :user, @user, :url => { :action => "add" }, :html => { :class => nil } do |f| %>
+<% labelled_tabular_form_for :user, @user, :url => { :action => "create" }, :html => { :class => nil } do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<p><label><%= check_box_tag 'send_information', 1, true %> <%= l(:label_send_information) %></label></p>
<p>