Class: Carnival::OmniauthCallbacksController

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

Instance Method Summary collapse

Instance Method Details

#facebookObject



2
3
4
5
6
7
8
9
10
11
12
13
# File 'app/controllers/carnival/omniauth_callbacks_controller.rb', line 2

def facebook
  # You need to implement the method below in your model (e.g. app/models/user.rb)
  @user = Carnival::AdminUser.find_for_omni_auth(request.env["omniauth.auth"])

  if @user.persisted?
     @user, :event => :authentication #this will throw if @user is not activated
    set_flash_message(:notice, :success, :kind => "Facebook") if is_navigational_format?
  else
    session["devise.facebook_data"] = request.env["omniauth.auth"]
    redirect_to new_user_registration_url
  end
end

#google_oauth2Object



15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/carnival/omniauth_callbacks_controller.rb', line 15

def google_oauth2
  user = Carnival::AdminUser.find_for_omni_auth(request.env["omniauth.auth"])
  if user.persisted?
    flash.notice = "Signed in Through Google!"
     user
  else
    session["devise.user_attributes"] = user.attributes
    flash.notice = "You are almost Done! Please provide a password to finish setting up your account"
    redirect_to new_user_registration_url
  end
end