Class: Billfold::IdentitiesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/billfold/identities_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject



33
34
35
36
37
38
39
40
# File 'app/controllers/billfold/identities_controller.rb', line 33

def destroy
  identity.destroy
  respond_to do |format|
    format.html { redirect_to :index }
    format.json { head 200 }
    format.xml  { head 200 }
  end
end

#indexObject



9
10
11
12
13
14
15
# File 'app/controllers/billfold/identities_controller.rb', line 9

def index
  respond_to do |format|
    format.html {}
    format.json { render :json => identities }
    format.xml  { render :xml  => identities }
  end
end

#update_or_createObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/billfold/identities_controller.rb', line 17

def update_or_create
  omniauth_hash = request.env['omniauth.auth'] || {}
  identity = Billfold.identity_class.update_or_create!({
    :provider => params[:provider],
    :value    => omniauth_hash['uid'],
    :data     => omniauth_hash['user_info'],
    :user     => current_user
  })
  self.current_user ||= identity.user
  respond_to do |format|
    format.html { redirect_to '/' }
    format.json { head 201 }
    format.xml  { head 201 }
  end
end