Class: Omnisocial::AuthController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/omnisocial/auth_controller.rb

Instance Method Summary collapse

Instance Method Details

#callbackObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/omnisocial/auth_controller.rb', line 13

def callback
   = case request.env['rack.auth']['provider']
    when 'twitter' then
      Omnisocial::TwitterAccount.find_or_create_from_auth_hash(request.env['rack.auth'])
    when 'facebook' then
      Omnisocial::FacebookAccount.find_or_create_from_auth_hash(request.env['rack.auth'])
    when 'linked_in' then
      Omnisocial::LinkedInAccount.find_or_create_from_auth_hash(request.env['rack.auth'])
  end

  self.current_user = .find_or_create_user

  flash[:notice] = 'You have logged in successfully.'
  redirect_back_or_default(root_path)
end

#destroyObject



34
35
36
37
# File 'app/controllers/omnisocial/auth_controller.rb', line 34

def destroy
  logout!
  redirect_to(root_path)
end

#failureObject



29
30
31
32
# File 'app/controllers/omnisocial/auth_controller.rb', line 29

def failure
  flash[:error] = "We had trouble signing you in. Did you make sure to grant access? Please select a service below and try again."
  render :action => 'new'
end

#newObject



6
7
8
9
10
11
# File 'app/controllers/omnisocial/auth_controller.rb', line 6

def new
  if current_user?
    flash[:notice] = 'You are already signed in. Please sign out if you want to sign in as a different user.'
    redirect_to(root_path)
  end
end