Module: NewsmastMastodon::Concerns::CustomAuthenticationBehavior

Extended by:
ActiveSupport::Concern
Includes:
NonChannelHelper
Defined in:
app/controllers/newsmast_mastodon/concerns/custom_authentication_behavior.rb

Instance Method Summary collapse

Methods included from NonChannelHelper

#is_non_channel?

Instance Method Details

#createObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/newsmast_mastodon/concerns/custom_authentication_behavior.rb', line 7

def create

  if client_credentials? || authorization_code?
    super
    return
  end

  if NewsmastMastodon::LoginService.new(oauth_params).two_factor_enabled?
    return render_error(I18n.t('login_service.errors.two_factor_enabled'))
  end

  error_message = if ENV.fetch('LOCAL_DOMAIN', nil) == 'thebristolcable.social' || Rails.env.development?
    NewsmastMastodon::LoginService.new(oauth_params). || nil
  elsif is_non_channel?
    NewsmastMastodon::LoginService.new(oauth_params). || nil
  else
    NewsmastMastodon::LoginService.new(oauth_params). || nil
  end

  error_message.nil? ? super : render_error(error_message)
end