From: Tom Hughes Date: Wed, 21 Jul 2021 18:24:31 +0000 (+0100) Subject: Merge remote-tracking branch 'upstream/pull/3257' X-Git-Tag: live~2056 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/f1935b1c5786de8f27bee9b6b2da2f28f650468f?hp=44199f23e1520623555eac2de6a2e97e3ed0e4ad Merge remote-tracking branch 'upstream/pull/3257' --- diff --git a/Gemfile.lock b/Gemfile.lock index a5ba172de..932435b34 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -53,7 +53,7 @@ GEM activerecord (6.1.4) activemodel (= 6.1.4) activesupport (= 6.1.4) - activerecord-import (1.1.0) + activerecord-import (1.2.0) activerecord (>= 3.2) activestorage (6.1.4) actionpack (= 6.1.4) @@ -77,7 +77,7 @@ GEM autoprefixer-rails (10.2.5.1) execjs (> 0) aws-eventstream (1.1.1) - aws-partitions (1.478.0) + aws-partitions (1.479.0) aws-sdk-core (3.117.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.239.0) @@ -115,7 +115,7 @@ GEM bootstrap_form (4.5.0) actionpack (>= 5.2) activemodel (>= 5.2) - brakeman (5.0.4) + brakeman (5.1.1) browser (5.3.1) builder (3.2.4) bzip2-ffi (1.1.0) @@ -416,7 +416,7 @@ GEM rubocop-ast (>= 1.7.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.7.0) + rubocop-ast (1.8.0) parser (>= 3.0.1.1) rubocop-minitest (0.14.0) rubocop (>= 0.90, < 2.0) @@ -433,7 +433,7 @@ GEM ruby-progressbar (1.11.0) ruby-vips (2.1.2) ffi (~> 1.12) - ruby2_keywords (0.0.4) + ruby2_keywords (0.0.5) rubyzip (2.3.2) sanitize (5.2.3) crass (~> 1.0.2) diff --git a/app/assets/javascripts/oauth.js b/app/assets/javascripts/oauth.js index d688590b0..0c3538c51 100644 --- a/app/assets/javascripts/oauth.js +++ b/app/assets/javascripts/oauth.js @@ -1,26 +1,11 @@ -//= require ohauth/ohauth - $(document).ready(function () { var application_data = $("head").data(); - function makeAbsolute(url) { - var a = document.createElement("a"); - a.href = url; - return a.href; - } - - if (application_data.token) { - var headerGenerator = window.ohauth.headerGenerator({ - consumer_key: application_data.consumerKey, - consumer_secret: application_data.consumerSecret, - token: application_data.token, - token_secret: application_data.tokenSecret - }); - - $.ajaxPrefilter(function (options, jqxhr) { + if (application_data.oauthToken) { + $.ajaxPrefilter(function (options) { if (options.oauth) { options.headers = options.headers || {}; - options.headers.Authorization = headerGenerator(options.type, makeAbsolute(options.url), jqxhr.data); + options.headers.Authorization = "Bearer " + application_data.oauthToken; } }); } diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index 3bec5fe36..0023286bf 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -1035,20 +1035,11 @@ tr.turn:hover { /* Overrides for pages that use new layout conventions */ -.users-new, -.users-create, -.users-terms, -.users-confirm { - .content-heading .content-inner { - height: 200px; - } -} - .header-illustration { background-position: 0 0; background-repeat: no-repeat; - position: absolute; - height: 200px; + position: relative; + min-height: 200px; width: 100%; left: 0; bottom: 0; @@ -1068,9 +1059,10 @@ tr.turn:hover { &.new-user-arm { height: 110px; width: 130px; - left: 260px; - top: 160px; + left: 280px; + top: 180px; background-image: image-url("sign-up-illustration-arm.png"); + position: absolute; z-index: 100; } } diff --git a/app/controllers/api/user_preferences_controller.rb b/app/controllers/api/user_preferences_controller.rb index 40ccfccbb..02a23095a 100644 --- a/app/controllers/api/user_preferences_controller.rb +++ b/app/controllers/api/user_preferences_controller.rb @@ -1,4 +1,4 @@ -# Update and read user preferences, which are arbitrayr key/val pairs +# Update and read user preferences, which are arbitrary key/val pairs module Api class UserPreferencesController < ApiController before_action :authorize diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 2083627f5..0884964ed 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -17,7 +17,6 @@ class ApplicationController < ActionController::Base helper_method :current_user helper_method :oauth_token - helper_method :preferred_langauges private @@ -67,7 +66,7 @@ class ApplicationController < ActionController::Base end def require_oauth - @oauth_token = current_user.access_token(Settings.oauth_key) if current_user && Settings.key?(:oauth_key) + @oauth_token = current_user.oauth_token(Settings.oauth_application) if current_user && Settings.key?(:oauth_application) end ## diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index f30ece3ec..594038939 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -47,7 +47,7 @@ class IssuesController < ApplicationController @new_comment = IssueComment.new(:issue => @issue) end - # Status Transistions + # Status Transitions def resolve if @issue.resolve @issue.updated_by = current_user.id diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index faf538fa9..c9f165d52 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -58,13 +58,7 @@ module ApplicationHelper end data[:location] = session[:location] if session[:location] - - if oauth_token - data[:token] = oauth_token.token - data[:token_secret] = oauth_token.secret - data[:consumer_key] = oauth_token.client_application.key - data[:consumer_secret] = oauth_token.client_application.secret - end + data[:oauth_token] = oauth_token.token if oauth_token data end diff --git a/app/helpers/banner_helper.rb b/app/helpers/banner_helper.rb index fef6eaa5e..17c6eace3 100644 --- a/app/helpers/banner_helper.rb +++ b/app/helpers/banner_helper.rb @@ -28,7 +28,7 @@ module BannerHelper index = cval.to_i cookies[ckey] = index - 1 if index.positive? - # pick banner with mininum queue position + # pick banner with minimum queue position next if index > min_index # or if equal queue position, pick banner with soonest end date (i.e. next expiring) diff --git a/app/models/concerns/consistency_validations.rb b/app/models/concerns/consistency_validations.rb index 00c6ce993..8c89f61de 100644 --- a/app/models/concerns/consistency_validations.rb +++ b/app/models/concerns/consistency_validations.rb @@ -3,7 +3,7 @@ module ConsistencyValidations # Generic checks that are run for the updates and deletes of # node, ways and relations. This code is here to avoid duplication, - # and allow the extention of the checks without having to modify the + # and allow the extension of the checks without having to modify the # code in 6 places for all the updates and deletes. Some of these tests are # needed for creates, but are currently not run :-( # This will throw an exception if there is an inconsistency diff --git a/app/models/user.rb b/app/models/user.rb index 4b471f60d..8b8f31676 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -68,7 +68,7 @@ class User < ApplicationRecord has_many :client_applications has_many :oauth_tokens, -> { order(:authorized_at => :desc).preload(:client_application) }, :class_name => "OauthToken" - has_many :oauth2_applications, :class_name => Doorkeeper.config.application_model.name, :foreign_key => :owner_id + has_many :oauth2_applications, :class_name => Doorkeeper.config.application_model.name, :as => :owner has_many :access_grants, :class_name => Doorkeeper.config.access_grant_model.name, :foreign_key => :resource_owner_id has_many :access_tokens, :class_name => Doorkeeper.config.access_token_model.name, :foreign_key => :resource_owner_id @@ -283,11 +283,23 @@ class User < ApplicationRecord end ## - # return an oauth access token for a specified application + # return an oauth 1 access token for a specified application def access_token(application_key) ClientApplication.find_by(:key => application_key).access_token_for_user(self) end + ## + # return an oauth 2 access token for a specified application + def oauth_token(application_id) + application = Doorkeeper.config.application_model.find_by(:uid => application_id) + + Doorkeeper.config.access_token_model.find_or_create_for( + :application => application, + :resource_owner => self, + :scopes => application.scopes + ) + end + def fingerprint digest = Digest::SHA256.new digest.update(email) diff --git a/app/views/confirmations/confirm.html.erb b/app/views/confirmations/confirm.html.erb index fde545546..7350f8628 100644 --- a/app/views/confirmations/confirm.html.erb +++ b/app/views/confirmations/confirm.html.erb @@ -1,6 +1,8 @@ +<% content_for :heading_class, "pb-0" %> <% content_for :heading do %> -

<%= t ".heading" %>

-
+
+

<%= t ".heading" %>

+
<% end %> <% if params[:confirm_string] %> diff --git a/app/views/messages/inbox.html.erb b/app/views/messages/inbox.html.erb index a27d7f15c..4f2925b14 100644 --- a/app/views/messages/inbox.html.erb +++ b/app/views/messages/inbox.html.erb @@ -2,8 +2,11 @@ <%= javascript_include_tag "messages" %> <% end %> +<% content_for :heading_class, "pb-0" %> + <% content_for :heading do %> -