]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/4329'
authorTom Hughes <tom@compton.nu>
Tue, 28 Nov 2023 22:21:50 +0000 (22:21 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 28 Nov 2023 22:21:50 +0000 (22:21 +0000)
app/controllers/users_controller.rb
app/views/site/welcome.html.erb
config/locales/en.yml

index 36c9f4e2288f06185726045826ae82ed9d927bb0..f79c284e3e499bf6b70475b0380141034032e316 100644 (file)
@@ -197,19 +197,7 @@ class UsersController < ApplicationController
 
           flash[:matomo_goal] = Settings.matomo["goals"]["signup"] if defined?(Settings.matomo)
 
-          referer = welcome_path
-
-          begin
-            uri = URI(session[:referer])
-            %r{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 StandardError
-            # Use default
-          end
+          referer = welcome_path(welcome_options)
 
           if current_user.status == "active"
             session[:referer] = referer
@@ -321,6 +309,21 @@ class UsersController < ApplicationController
 
   private
 
+  def welcome_options
+    uri = URI(session[:referer]) if session[:referer].present?
+
+    return { "oauth_return_url" => uri&.to_s } if uri&.path == oauth_authorization_path
+
+    begin
+      %r{map=(.*)/(.*)/(.*)}.match(uri.fragment) do |m|
+        editor = Rack::Utils.parse_query(uri.query).slice("editor")
+        return { "zoom" => m[1], "lat" => m[2], "lon" => m[3] }.merge(editor)
+      end
+    rescue StandardError
+      # Use default
+    end
+  end
+
   ##
   # ensure that there is a "user" instance variable
   def lookup_user_by_name
index b05620f599efbbc74ed6f32603d4c2e77d312f45..8ec32ea9c86e8446f870b9f3506ccec2158cf17a 100644 (file)
 </div>
 
 <div class='clearfix text-center'>
-  <p class="display-5"><a href="<%= edit_path %>" class="button start-mapping"><%= t ".start_mapping" %></a></p>
+  <p class="display-5">
+<% if params[:oauth_return_url] %>
+  <a class="btn btn-primary" href="<%= params[:oauth_return_url] %>"><%= t ".continue_authorization" %></a>
+<% else %>
+  <a class="button btn btn-primary start-mapping" href="<%= edit_path %>"><%= t ".start_mapping" %></a>
+<% end %>
+  </p>
 </div>
 
 <div class='alert alert-primary'>
index 546bf669c1a8ae353076efee24fa290f77a2ad85..8b0745118b4adfa2fb06f9e16efbe5414bf17e0e 100644 (file)
@@ -2383,6 +2383,7 @@ en:
         automated_edits: Automated Edits
         automated_edits_url: https://wiki.openstreetmap.org/wiki/Automated_Edits_code_of_conduct
       start_mapping: Start Mapping
+      continue_authorization: Continue Authorization
       add_a_note:
         title: No Time To Edit? Add a Note!
         para_1: |