Class: OauthsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/oauths_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#not_authenticated, #set_locale

Instance Method Details

#callbackObject


8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/oauths_controller.rb', line 8

def callback
  provider = auth_params[:provider]
  if @user = (provider)
    redirect_to root_path, notice: "Logged in from #{provider.titleize}"
  elsif logged_in?
    (provider)
    redirect_to root_path, notice: "Successfully link #{provider.titleize}"
  else
    @user = create_from(provider)
    reset_session
    (@user)
    redirect_to root_path, notice: "Logged in from #{provider.titleize}"
  end
end

#destroyObject


23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/oauths_controller.rb', line 23

def destroy
  provider = auth_params[:provider]
  authentication = current_user.authentications.find_by_provider(provider)
  if authentication.present?
    authentication.destroy
    flash[:notice] = "You have unlinked your #{provider.titleize} account."
  else
    flash[:alert] = "You do not have a linked #{provider.titleize} account."
  end
  redirect_to root_path
end

#oauthObject


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

def oauth
  (auth_params[:provider])
end