realdoug / omniauth-salesforce

OmniAuth strategy for salesforce.com
MIT License
65 stars 90 forks source link

Rails: Salesforce Omniauth able to logout from my application but not logout from salesforce #21

Closed rajcybage closed 8 years ago

rajcybage commented 8 years ago

I have one Rails application where I am using salesforce omniauth

I am able to logout by making reset_session. But I am not completely logout from salesforce as when user again click login it will redirect to omniauth and login automatically.

I did below steps

gem 'omniauth-salesforce'

and model

class User < ActiveRecord::Base
    def self.from_omniauth(auth)
      where(auth.slice(:provider, :uid).permit!).first_or_initialize.tap do |user|
        user.provider = auth.provider
        user.uid = auth.uid
        user.name = auth.info.name
        user.oauth_token = auth.credentials.token
        user.refresh_token = auth.credentials.refresh_token
        user.instance_url = auth.credentials.instance_url
        user.save!
      end
    end
  end
class SessionsController < ApplicationController
    def create
      user = User.from_omniauth(env["omniauth.auth"])
      session[:user_id] = user.id
      redirect_to root_url
    end

    def destroy
      session[:user_id] = nil
      redirect_to root_url
    end
  end
 end

I am new on salesforce omniauth. Please suggest how can I able to logout from my app as well as salesforce both.

realdoug commented 8 years ago

OAuth2 (and thus omniauth-salesforce) cannot actually end your salesforce browser session. That's between Google Chrome (or IE ect) & Salesforce.com. All we can do is invalidate the refresh token that was issued as part of the OAuth2 process.

rajcybage commented 8 years ago

Thank you @realdoug