Class: CrowdintAuth::OmniauthCallbacksController

Inherits:
Devise::OmniauthCallbacksController
  • Object
show all
Defined in:
app/controllers/crowdint_auth/omniauth_callbacks_controller.rb

Instance Method Summary collapse

Instance Method Details

#create_user_record(email, name) ⇒ Object



8
9
10
# File 'app/controllers/crowdint_auth/omniauth_callbacks_controller.rb', line 8

def create_user_record(email, name)
  user_class.create(:email => email, :name => name)
end

#google_appsObject



12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/crowdint_auth/omniauth_callbacks_controller.rb', line 12

def google_apps
  auth_hash = request.env['omniauth.auth']
  email = auth_hash.info['email']

  user = user_class.find_by_email(email)
  user ||= create_user_record(email, auth_hash.info['name'])

  if user.persisted?
     user
  end
end

#google_apps_sign_inObject



24
25
26
# File 'app/controllers/crowdint_auth/omniauth_callbacks_controller.rb', line 24

def 
  redirect_to user_omniauth_authorize_path :google_apps
end

#user_classObject



4
5
6
# File 'app/controllers/crowdint_auth/omniauth_callbacks_controller.rb', line 4

def user_class
  ::User
end