Sha256: 24a9b558f0899af8e522512082451186ff2093c36b9e00d4f4ecb1c94e924f8d

Contents?: true

Size: 1.94 KB

Versions: 64

Compression:

Stored size: 1.94 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_to do |format|
        format.html { respond_with resource, location: after_sign_in_path_for(resource) }
        format.json { render json: { success: true, resource_name => { id: resource.id, email: resource.email, first_name: resource.first_name, last_name: resource.last_name, authentication_token: (resource.respond_to?(:authentication_token) ? resource.authentication_token : nil) } } }
      end
    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

64 entries across 64 versions & 1 rubygems

Version Path
contour-2.7.0 app/controllers/contour/sessions_controller.rb
contour-2.7.0.beta1 app/controllers/contour/sessions_controller.rb
contour-2.6.0 app/controllers/contour/sessions_controller.rb
contour-2.6.0.rc app/controllers/contour/sessions_controller.rb
contour-2.6.0.beta8 app/controllers/contour/sessions_controller.rb
contour-2.6.0.beta7 app/controllers/contour/sessions_controller.rb
contour-2.6.0.beta6 app/controllers/contour/sessions_controller.rb
contour-2.6.0.beta5 app/controllers/contour/sessions_controller.rb
contour-2.6.0.beta4 app/controllers/contour/sessions_controller.rb
contour-2.6.0.beta3 app/controllers/contour/sessions_controller.rb
contour-2.6.0.beta2 app/controllers/contour/sessions_controller.rb
contour-2.6.0.beta1 app/controllers/contour/sessions_controller.rb
contour-2.5.0 app/controllers/contour/sessions_controller.rb
contour-2.5.0.beta1 app/controllers/contour/sessions_controller.rb
contour-2.4.0 app/controllers/contour/sessions_controller.rb
contour-2.4.0.rc2 app/controllers/contour/sessions_controller.rb
contour-2.4.0.rc app/controllers/contour/sessions_controller.rb
contour-2.4.0.beta3 app/controllers/contour/sessions_controller.rb
contour-2.4.0.beta2 app/controllers/contour/sessions_controller.rb
contour-2.4.0.beta1 app/controllers/contour/sessions_controller.rb