0

I do login authentication with google in rails app,I had problem with when I logout it will redirect to my index page but can not able to logout from google account
I was doing first time login authentication,Please can any one help me

Thank you in advance

Here I write my code where i was wrong

def create
    @user = Authentication.find_or_create_from_auth_hash(request.env["omniauth.auth"])
    session[:user_id] = @user.id
    redirect_to '/'
end
def destroy
    session[:user_id] = nil
    redirect_to '/login'
end
Rin
  • 81
  • 1
  • 2
  • 11
  • You want to logout from your google account as well? or logout from your application only? – Vishal May 30 '19 at 04:37
  • I am login with my google account , I want when i logout from application it would be logout from google account also – Rin May 30 '19 at 04:59

1 Answers1

1

This is not how it works.

Consider doing this: Open your rails app -> Login with Google -> You'll see your rails app dashboard -> Now open a new tab and open google.com -> Logout from there -> Now switch back to your rails app and reload the page.

Even though you're logged out of Google, you're still signed in to your Rails app.

This means that your rails app is not exactly your google account. They both are independent. Your rails app(through Omniauth) just requests the Google data with an OAuth API, which will authorize the app and then sends the access token, and with this token, you get the google data(like email), etc.

However, if you still want to log out the user from the Google account, You can use alternatives like in this answer and multiple answers from this thread.