Files
mozo-backend/app/controllers/users/omniauth_callbacks_controller.rb
T

31 lines
992 B
Ruby

class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def passthru
return show_404 alert: 'Test'
send(params[:provider]) and return if available_action?(params[:provider])
# Or alternatively,
# raise ActionController::RoutingError.new('Not Found')
end
def facebook
@user = User.find_for_oauth(request.env["omniauth.auth"], current_user)
if @user.persisted?
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", kind: @user.provider.to_s.capitalize
sign_in @user
redirect_to user_obtain_token_path, event: :authentication, current_user: @user
else
session["devise.facebook_data"] = request.env["omniauth.auth"]
Rails.logger.error("Failed to persist user: #{@user.errors.full_messages.join(', ')}")
redirect_to '/'
end
end
def instagram
facebook # same same
end
def failure(env = {})
show_404 alert: "There was a problem authorizing and identifier the user"
end
end