Class: AuthenticationsController
- Inherits:
-
DeviseController
- Object
- DeviseController
- AuthenticationsController
- Defined in:
- app/controllers/authentications_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/authentications_controller.rb', line 10 def create omniauth = request.env["omniauth.auth"] authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'].to_s) if authentication flash[:notice] = I18n.t("devise.sessions.signed_in") sign_in_and_redirect(:user, authentication.user) elsif current_user current_user.apply_omniauth(omniauth, false) current_user.save flash[:notice] = I18n.t("devise.sessions.signed_already") redirect_to authentications_url else @user = User.new @user.apply_omniauth(omniauth, true) if @user.save flash[:notice] = I18n.t("devise.confirmations.send_instructions") sign_in_and_redirect(:user, @user) else session[:omniauth] = omniauth.except('extra') render :controller => "registrations", :template => "devise/registrations/new" end end end |
#destroy ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/authentications_controller.rb', line 34 def destroy @authentication = current_user.authentications.find_by_id(params[:id]) if @authentication @authentication.destroy flash[:notice] = I18n.t("devise.sessions.signed_out") redirect_to authentications_url else flash[:error] = I18n.t("devise_russian.authentication_not_found") redirect_to "/" end end |
#devise_mapping ⇒ Object
50 51 52 |
# File 'app/controllers/authentications_controller.rb', line 50 def devise_mapping @devise_mapping ||= Devise.mappings[:user] end |
#failure ⇒ Object
46 47 48 |
# File 'app/controllers/authentications_controller.rb', line 46 def failure redirect_to devise_russian.new_user_session_url end |
#index ⇒ Object
5 6 7 8 |
# File 'app/controllers/authentications_controller.rb', line 5 def index @meta_title = I18n.t("devise_russian.my_authentications") @authentications = current_user.authentications end |