Class: ServicesController

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

Overview

Copyright © 2010-2011, Diaspora Inc. This file is

licensed under the Affero General Public License version 3 or later.  See
the COPYRIGHT file.

Instance Method Summary collapse

Instance Method Details

#createObject


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

def create
  service = Service.initialize_from_omniauth( omniauth_hash )

  if current_user.services << service
    no_profile_image_before_update = no_profile_image?
    current_user.update_profile_with_omniauth(service.info)
    fetch_photo(service) if no_profile_image_before_update

    flash[:notice] = I18n.t 'services.create.success'
  else
    flash[:error] = I18n.t 'services.create.failure'
  end
  redirect_to_origin
end

#destroyObject


42
43
44
45
46
47
# File 'app/controllers/services_controller.rb', line 42

def destroy
  @service = current_user.services.find(params[:id])
  @service.destroy
  flash[:notice] = I18n.t 'services.destroy.success'
  redirect_to services_url
end

#failureObject


36
37
38
39
40
# File 'app/controllers/services_controller.rb', line 36

def failure
  logger.info "error in oauth #{params.inspect}"
  flash[:error] = t('services.failure.error')
  redirect_to services_url
end

#indexObject


17
18
19
# File 'app/controllers/services_controller.rb', line 17

def index
  @services = current_user.services
end