Class: HappySeed::Generators::GoogleoauthGenerator

Inherits:
HappySeedGenerator
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/happy_seed/googleoauth/googleoauth_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.fingerprintObject



9
10
11
# File 'lib/generators/happy_seed/googleoauth/googleoauth_generator.rb', line 9

def self.fingerprint
  gem_available? 'omniauth-google-oauth2'
end

Instance Method Details

#install_facebookObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/generators/happy_seed/googleoauth/googleoauth_generator.rb', line 13

def install_facebook
  return if already_installed

  require_generator OmniauthGenerator

  gem 'omniauth-google-oauth2'
  gem 'google-api-client', require: "google/api_client"

  Bundler.with_clean_env do
    run "bundle install --without production"
  end

  directory 'docs'
  directory 'app'

  add_omniauth :google_oauth2, 'email,profile,offline", prompt: "consent', 'GoogleAppsClient', "google_oauth2"
  insert_into_file "app/models/identity.rb", "\n      identity.refreshtoken = auth.credentials.refresh_token", after: "identity.accesstoken = auth.credentials.token"
  migration_template("add_refresh_token_to_identity.rb", "db/migrate/add_refresh_token_to_identity.rb" )
end