Now suppose you have a Google uid . Just create a user from your seeds, for example:
user = User.new( provider: "google", uid: "your-google-id", email: " davea@gmail.com ", name: "Your name" ) user.roles << admin_role
At the same time, when you log in using Google, omniauth logic should be able to find the seven user, which means that you can act as an administrator.
Please note that this assumes that you do not need the Google oauth token for further operation, since you do not have it, and it is not saved from your from_omniauth if the user record already exists.
PS from your sample code, Oauth information is stored directly in the User model ( provider and uid ). However, I am afraid that the user will not be able to log in with Facebook and Google at the same time, since both of them will want to save these two fields.
Update: inserting a model from my code base, which is a separate model from User , which allows several providers to log in. Of course, the controller needs to be updated to use Authorization instead of User . Just in case, this helps.
class Authorization < ActiveRecord::Base belongs_to :user def self.from_omniauth(auth) authorization = where(auth.slice(:provider, :uid)).first_or_create return authorization if authorization.user if user = User.where(email: auth.info.email).first authorization.bind_user(user) else user = authorization.create_user(auth.info) end authorization end def bind_user(user) self.user = user save end def create_user(info) user = User.new( email: info.email, password: Devise.friendly_token[0, 20], first_name: info.first_name, last_name: info.last_name, ) user.save(validate: false) bind_user(user) user end end