Sha256: 9259998286433d0b8fe4503600fe4138a37828112b5094b7f3e10d61fa45019a

Contents?: true

Size: 944 Bytes

Versions: 4

Compression:

Stored size: 944 Bytes

Contents

module C80NewsTz
  class SessionsController < ApplicationController

    def create
      #render text: request.env['omniauth.auth'].to_yaml

      begin
        @user = User.from_omniauth(request.env['omniauth.auth'])
        session[:user_id] = @user.id
        flash[:success] = "Welcome, #{@user.name}!"
      rescue => e
        Rails.logger.debug(e)
        flash[:warning] = 'There was an error while try to authenticate you...'
      end

      # Rails.logger.debug("<SessionsController.create> request.env['omniauth.origin'] = " + request.env['omniauth.origin'])
      redirect_to request.env['omniauth.origin']

    end

    def destroy
      #if current_user
      begin
        session.delete(:user_id)
      rescue
      end

      flash[:success] = 'See you!'

      redirect_to request.referer

    end

    def auth_failure
      # redirect_to request.referer
      redirect_to request.env['omniauth.origin']
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
c80_news_tz-0.1.1.26 app/controllers/c80_news_tz/sessions_controller.rb
c80_news_tz-0.1.1.25 app/controllers/c80_news_tz/sessions_controller.rb
c80_news_tz-0.1.1.24 app/controllers/c80_news_tz/sessions_controller.rb
c80_news_tz-0.1.1.23 app/controllers/c80_news_tz/sessions_controller.rb