- # Render the signup page unless we have already been
- # redirected or have managed to save the user
- if response.location.nil? and @user.new_record?
- render :action => "new"
+ if params[:referer]
+ redirect_to params[:referer]
+ else
+ redirect_to :action => :account, :display_name => @user.display_name
+ end
+ elsif Acl.no_account_creation(request.remote_ip, params[:user][:email].split("@").last)
+ render :action => 'blocked'
+ else
+ @user = User.new(params[:user])
+
+ @user.status = "pending"
+ @user.data_public = true
+ @user.description = "" if @user.description.nil?
+ @user.creation_ip = request.remote_ip
+ @user.languages = request.user_preferred_languages
+ @user.terms_agreed = Time.now.getutc
+ @user.terms_seen = true
+ @user.openid_url = nil if @user.openid_url and @user.openid_url.empty?
+
+ if @user.save
+ flash[:piwik_goal] = PIWIK_SIGNUP_GOAL if defined?(PIWIK_SIGNUP_GOAL)
+ flash[:notice] = t 'user.new.flash create success message', :email => @user.email
+ Notifier.signup_confirm(@user, @user.tokens.create(:referer => session.delete(:referer))).deliver
+ session[:token] = @user.tokens.create.token
+ redirect_to :action => 'login', :referer => params[:referer]
+ else
+ render :action => 'new', :referer => params[:referer]