0

I am using Devise and Omniauth to offer login via native(devise), facebook and google+

Users can theoretically login with any method in succession and I would like to register the last method of authentication. For Facebook and G+ I am able to record it in the find_* method on my user table but Devise 'native' auth is a closed book.

The best approach i can think of is to update a session variable in a controller just prior to login and then use a warden authentication callback or subclass the sessions controller

as here: Ruby on Rails Devise code after login

to update the user with the auth type straight after but it seems a little messy.

Community
  • 1
  • 1
Ian
  • 315
  • 1
  • 6
  • 13

1 Answers1

1

Devise has a method that you can call, which will run after database auth in your user model, you could then update the attribute here.

class User < ActiveRecord::Base
...
devise :database_authenticatable, :omniauthable .... 
...
  def after_database_authentication
    update_attribute(:auth_type, 'database')
  end
...
end
Yule
  • 9,668
  • 3
  • 51
  • 72