Skip to content

Instantly share code, notes, and snippets.

@mokevnin
Created February 6, 2012 19:10
Show Gist options
  • Select an option

  • Save mokevnin/1754139 to your computer and use it in GitHub Desktop.

Select an option

Save mokevnin/1754139 to your computer and use it in GitHub Desktop.
class Web::Account::FacebookController < Web::Account::ApplicationController
def create_link
fb_hash = FacebookIntegration.get_auth_hash(
create_link_account_facebook_url, params['code'])
FacebookService.create_link(current_user, fb_hash)
redirect_to account_root_url,
:notice => t('web.messages.account.facebook.linked')
rescue UserBlockedError
redirect_to account_root_url,
:error => t('web.messages.users.blocked')
rescue AlreadyLinkedError
redirect_to account_root_url,
:error => t('web.messages.account.facebook.already_linked')
rescue ServiceError
redirect_to account_root_url,
:error => t('web.messages.account.facebook.link_failure')
end
def destroy
if current_user.facebook
current_user.facebook.destroy
redirect_to account_root_url,
:notice => I18n.t("web.messages.account.facebook.destroyed")
else
redirect_to account_root_url,
:notice => I18n.t("web.messages.account.facebook.not_linked")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment