Module: GoogleAuthentication::ActsAsGoogleUser

Defined in:
lib/google_authentication/acts_as_google_user.rb

Overview

enclose AR methods used to give a model the ability to authenticate as a Google User using devise + omniauth combo

Defined Under Namespace

Modules: Model

Constant Summary collapse

FORBIDDEN_MODULES =

Devise forbidden modules, useless in this context

[:database_authenticable, :recoverable, :registrable, :encryptable, :lockable, :validatable, :confirmable]
ALLOWED_MODULES =

Devise allowed modules

[:omniauthable, :token_authenticable, :trackable, :timeoutable, :rememberable]
@@devise_modules_to_include =

default devise modules

[:omniauthable]

Instance Method Summary collapse

Instance Method Details

#acts_as_google_user(*modules) ⇒ Object

Configure a model to be used with devise and google authentication

Parameters:

  • modules (Array)

    a list of symbols used with a devise call



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/google_authentication/acts_as_google_user.rb', line 20

def acts_as_google_user *modules
  # assign devise modules to module variable
  if modules.empty?
    self.devise_modules_to_include = [:omniauthable]
  else
    # restrict modules given to devise
    self.devise_modules_to_include = (modules + [:omniauthable] - FORBIDDEN_MODULES) & ALLOWED_MODULES
  end
  # include model methods
  include ActsAsGoogleUser::Model
end