Class: AuthorizationsController
- Inherits:
-
BaseController
- Object
- ApplicationController
- BaseController
- AuthorizationsController
- Defined in:
- app/controllers/authorizations_controller.rb
Instance Method Summary collapse
Methods inherited from BaseController
#advertise, #cache_action?, #css_help, #footer_content, #homepage_features, #plaxo, #rss_site_index, #site_index
Methods included from LocalizedApplication
#get_matching_ui_locale, #get_sorted_langs_from_accept_header, #get_valid_lang_from_accept_header, #set_locale
Methods included from AuthenticatedSystem
#login_by_token, #update_last_seen_at
Instance Method Details
#create ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/authorizations_controller.rb', line 4 def create omniauth = request.env['omniauth.auth'] #this is where you get all the data from your provider through omniauth provider_name = omniauth['provider'].to_s.capitalize @auth = Authorization.find_or_create_from_hash(omniauth, current_user) if logged_in? flash[:notice] = t('authorizations.create.success_existing_user', :provider => provider_name) elsif @auth.valid? flash[:notice] = t('authorizations.create.success_message', :provider => provider_name) UserSession.create(@auth.user, true) end if logged_in? redirect_to request.env['omniauth.origin'] || user_path(current_user) else flash[:notice] = @auth.user.errors..to_sentence redirect_to login_path end end |
#destroy ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/controllers/authorizations_controller.rb', line 30 def destroy @authorization = current_user..find(params[:id]) if @authorization.destroy flash[:notice] = t('authorizations.destroy.notice', :provider => @authorization.provider.to_s.capitalize) else flash[:notice] = @authorization.errors..to_sentence end redirect_to edit_account_user_path end |
#failure ⇒ Object
25 26 27 28 |
# File 'app/controllers/authorizations_controller.rb', line 25 def failure flash[:notice] = t('authorizations.failure.notice') redirect_to home_url end |