]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/user_controller.rb
Rework piwik configuration
[rails.git] / app / controllers / user_controller.rb
index dfacb9d5a2a70d0a2b39d564117ca648c0f1f28f..a7822e47fd436188d703fe55493482d9649a92cb 100644 (file)
@@ -86,14 +86,28 @@ class UserController < ApplicationController
         @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[:piwik_goal] = PIWIK["goals"]["signup"] if defined?(PIWIK)
+
+          referer = welcome_path
+
+          begin
+            uri = URI(session[:referer])
+            /map=(.*)\/(.*)\/(.*)/.match(uri.fragment) do |m|
+              editor = Rack::Utils.parse_query(uri.query).slice('editor')
+              referer = welcome_path({'zoom' => m[1],
+                                      'lat' => m[2],
+                                      'lon' => m[3]}.merge(editor))
+            end
+          rescue
+            # Use default
+          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
@@ -297,10 +311,14 @@ class UserController < ApplicationController
   end
 
   def confirm
-    if request.post? && (token = UserToken.find_by_token(params[:confirm_string]))
-      if token.user.active?
+    if request.post?
+      token = UserToken.find_by_token(params[:confirm_string])
+      if token && token.user.active?
         flash[:error] = t('user.confirm.already active')
         redirect_to :action => 'login'
+      elsif !token || token.expired?
+        flash[:error] = t('user.confirm.unknown token')
+        redirect_to :action => 'confirm'
       else
         user = token.user
         user.status = "active"