Merge remote-tracking branch 'tootsuite/master' into merge-upstream
Conflicts: app/javascript/styles/mastodon/components.scss
This commit is contained in:
@ -1,10 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ActivityPub::OutboxesController < Api::BaseController
|
||||
include SignatureVerification
|
||||
|
||||
before_action :set_account
|
||||
|
||||
def show
|
||||
@statuses = @account.statuses.permitted_for(@account, current_account).paginate_by_max_id(20, params[:max_id], params[:since_id])
|
||||
@statuses = @account.statuses.permitted_for(@account, signed_request_account).paginate_by_max_id(20, params[:max_id], params[:since_id])
|
||||
@statuses = cache_collection(@statuses, Status)
|
||||
|
||||
render json: outbox_presenter, serializer: ActivityPub::CollectionSerializer, adapter: ActivityPub::Adapter, content_type: 'application/activity+json'
|
||||
|
@ -15,6 +15,7 @@ class ApplicationController < ActionController::Base
|
||||
helper_method :current_flavour
|
||||
helper_method :current_skin
|
||||
helper_method :single_user_mode?
|
||||
helper_method :use_pam?
|
||||
|
||||
rescue_from ActionController::RoutingError, with: :not_found
|
||||
rescue_from ActiveRecord::RecordNotFound, with: :not_found
|
||||
@ -145,6 +146,10 @@ class ApplicationController < ActionController::Base
|
||||
@single_user_mode ||= Rails.configuration.x.single_user_mode && Account.exists?
|
||||
end
|
||||
|
||||
def use_pam?
|
||||
Devise.pam_authentication
|
||||
end
|
||||
|
||||
def current_account
|
||||
@current_account ||= current_user.try(:account)
|
||||
end
|
||||
|
@ -15,6 +15,11 @@ class Auth::RegistrationsController < Devise::RegistrationsController
|
||||
|
||||
protected
|
||||
|
||||
def update_resource(resource, params)
|
||||
params[:password] = nil if Devise.pam_authentication && resource.encrypted_password.blank?
|
||||
super
|
||||
end
|
||||
|
||||
def build_resource(hash = nil)
|
||||
super(hash)
|
||||
|
||||
|
@ -29,7 +29,11 @@ class Auth::SessionsController < Devise::SessionsController
|
||||
if session[:otp_user_id]
|
||||
User.find(session[:otp_user_id])
|
||||
elsif user_params[:email]
|
||||
User.find_for_authentication(email: user_params[:email])
|
||||
if use_pam? && Devise.check_at_sign && user_params[:email].index('@').nil?
|
||||
User.joins(:account).find_by(accounts: { username: user_params[:email] })
|
||||
else
|
||||
User.find_for_authentication(email: user_params[:email])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
11
app/controllers/concerns/signature_authentication.rb
Normal file
11
app/controllers/concerns/signature_authentication.rb
Normal file
@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module SignatureAuthentication
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
include SignatureVerification
|
||||
|
||||
def current_account
|
||||
super || signed_request_account
|
||||
end
|
||||
end
|
@ -1,6 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class StatusesController < ApplicationController
|
||||
include SignatureAuthentication
|
||||
include Authorization
|
||||
|
||||
layout 'public'
|
||||
|
@ -10,6 +10,7 @@ class StreamEntriesController < ApplicationController
|
||||
before_action :set_stream_entry
|
||||
before_action :set_link_headers
|
||||
before_action :check_account_suspension
|
||||
before_action :set_cache_headers
|
||||
|
||||
def show
|
||||
respond_to do |format|
|
||||
@ -20,6 +21,10 @@ class StreamEntriesController < ApplicationController
|
||||
end
|
||||
|
||||
format.atom do
|
||||
unless @stream_entry.hidden?
|
||||
skip_session!
|
||||
expires_in 3.minutes, public: true
|
||||
end
|
||||
render xml: OStatus::AtomSerializer.render(OStatus::AtomSerializer.new.entry(@stream_entry, true))
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user