Pass editing params through to welcome page
authorJohn Firebaugh <john.firebaugh@gmail.com>
Fri, 2 Aug 2013 21:36:38 +0000 (14:36 -0700)
committerJohn Firebaugh <john.firebaugh@gmail.com>
Mon, 12 Aug 2013 20:34:44 +0000 (13:34 -0700)
app/assets/javascripts/welcome.js
app/controllers/user_controller.rb

index 8cf9eb83b920b6fe0eca32da4c434b5cf4f728b8..5773bfd6dbc6260c935561f93e072816f25276f6 100644 (file)
@@ -21,7 +21,14 @@ $(document).ready(function() {
       }
     });
 
-    $('.start-mapping').attr('href', '/edit?zoom=17&lat=' + params.lat + '&lon=' + params.lon);
+    params = {
+      lat: params.lat,
+      lon: params.lon,
+      zoom: params.zoom || 17,
+      editor: params.editor
+    };
+
+    $('.start-mapping').attr('href', '/edit?' + $.param(params));
 
   } else if (navigator.geolocation) {
     $('.edit-geolocated').show();
index dfacb9d5a2a70d0a2b39d564117ca648c0f1f28f..fdef4ea04de9da617499567b76330001d0c1b3ff 100644 (file)
@@ -88,12 +88,19 @@ class UserController < ApplicationController
         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] = welcome_path
+            session[:referer] = referer
             successful_login(@user)
           else
             session[:token] = @user.tokens.create.token
-            Notifier.signup_confirm(@user, @user.tokens.create(:referer => welcome_path)).deliver
+            Notifier.signup_confirm(@user, @user.tokens.create(:referer => referer)).deliver
             redirect_to :action => 'confirm', :display_name => @user.display_name
           end
         else