module DoorkeeperSsoClient::Mixins::PassportBase::ClassMethods

Public Instance Methods

create_from_omniauth(auth_hash) click to toggle source
# File lib/doorkeeper_sso_client/mixins/passport_base.rb, line 14
def create_from_omniauth(auth_hash)
  uid = { uid: auth_hash["extra"]["passport_id"] }
  passport = where(uid).first || new(uid)
  passport.update_attributes!(
    secret: auth_hash["extra"]["passport_secret"],
    token: auth_hash["credentials"]["token"],
    refresh_token: auth_hash["credentials"]["refresh_token"],
    token_expiry:  auth_hash["credentials"]["expiry"],
    revoked_at: nil,
    revoke_reason: nil,
    last_login_at: Time.current,
    client_uid: auth_hash["extra"]["client_id"]
  )
end