Sha256: 06d5089d67efdaf90b3c29529f2643fe6a1979ba26161764e3a0c22a2857f60a

Contents?: true

Size: 1.6 KB

Versions: 21

Compression:

Stored size: 1.6 KB

Contents

require 'rss/2.0'
require 'open-uri'

class Contour::SessionsController < Devise::SessionsController

  def new
    @news_feed = ''
    unless Contour.news_feed.blank?
      begin
        open(Contour.news_feed, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE) do |http|
          response = http.read
          @news_feed = RSS::Parser.parse(response, false)
        end
      rescue => e
        logger.info "\n\nRSS Feed #{Contour.news_feed}\nRSS Feed Error: #{e}\n\n"
      end
    end

    super
  end

  # Overwrite Devise authentication to check if the user is typing another credential into the default box
  # if so, find alternative login methods for that user and forward the user to those login screens
  def create
    # resource = warden.authenticate!(auth_options)
    resource = warden.authenticate(auth_options)

    if resource
      set_flash_message(:notice, :signed_in) if is_navigational_format?
      sign_in(resource_name, resource)
      respond_with resource, location: after_sign_in_path_for(resource)
    else
      resource = resource_name.to_s.titleize.constantize.find_by_email(params[resource_name][:email])
      if resource and resource.respond_to?('authentications') and providers = resource.authentications.pluck(:provider).uniq and providers.size > 0
        redirect_to request.script_name + '/auth/' + providers.first
      elsif providers = Authentication.where(uid: params[resource_name][:email]).pluck(:provider).uniq and providers.size > 0
        redirect_to request.script_name + '/auth/' + providers.first
      else
        resource = warden.authenticate!(auth_options)
      end
    end
  end

end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
contour-1.1.0.rc2 app/controllers/contour/sessions_controller.rb
contour-1.1.0.rc app/controllers/contour/sessions_controller.rb
contour-1.0.5 app/controllers/contour/sessions_controller.rb
contour-1.1.0.pre2 app/controllers/contour/sessions_controller.rb
contour-1.1.0.pre app/controllers/contour/sessions_controller.rb
contour-1.0.4 app/controllers/contour/sessions_controller.rb
contour-1.0.3 app/controllers/contour/sessions_controller.rb
contour-1.0.2 app/controllers/contour/sessions_controller.rb
contour-1.0.1 app/controllers/contour/sessions_controller.rb
contour-1.0.0 app/controllers/contour/sessions_controller.rb
contour-1.0.0.rc2 app/controllers/contour/sessions_controller.rb
contour-1.0.0.rc app/controllers/contour/sessions_controller.rb
contour-1.0.0.beta12 app/controllers/contour/sessions_controller.rb
contour-1.0.0.beta11 app/controllers/contour/sessions_controller.rb
contour-1.0.0.beta10 app/controllers/contour/sessions_controller.rb
contour-1.0.0.beta9 app/controllers/contour/sessions_controller.rb
contour-1.0.0.beta8 app/controllers/contour/sessions_controller.rb
contour-1.0.0.beta7 app/controllers/contour/sessions_controller.rb
contour-1.0.0.beta6 app/controllers/contour/sessions_controller.rb
contour-1.0.0.beta5 app/controllers/contour/sessions_controller.rb