Merge remote-tracking branch 'tootsuite/master' into merge-upstream

Conflicts:
      app/javascript/styles/mastodon/components.scss
This commit is contained in:
David Yip
2018-02-02 08:39:52 -06:00
30 changed files with 244 additions and 95 deletions

View File

@ -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'

View File

@ -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

View File

@ -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)

View File

@ -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

View 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

View File

@ -1,6 +1,7 @@
# frozen_string_literal: true
class StatusesController < ApplicationController
include SignatureAuthentication
include Authorization
layout 'public'

View File

@ -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