+ @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)
+
+ begin
+ referer_params = Rack::Utils.parse_query(URI(session[:referer]).query)
+ referer = welcome_path(referer_params.slice(:lat, :lon, :zoom, :editor))
+ rescue
+ referer = welcome_path
+ end
+
+ if @user.status == "active"
+ session[:referer] = referer
+ successful_login(@user)
+ else
+ session[:token] = @user.tokens.create.token
+ Notifier.signup_confirm(@user, @user.tokens.create(:referer => referer)).deliver
+ redirect_to :action => 'confirm', :display_name => @user.display_name
+ end
+ else
+ render :action => 'new', :referer => params[:referer]
+ end