logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

omniauth_callbacks_controller.rb (932B)


  1. # frozen_string_literal: true
  2. class Auth::OmniauthCallbacksController < Devise::OmniauthCallbacksController
  3. skip_before_action :verify_authenticity_token
  4. def self.provides_callback_for(provider)
  5. provider_id = provider.to_s.chomp '_oauth2'
  6. define_method provider do
  7. @user = User.find_for_oauth(request.env['omniauth.auth'], current_user)
  8. if @user.persisted?
  9. sign_in_and_redirect @user, event: :authentication
  10. set_flash_message(:notice, :success, kind: provider_id.capitalize) if is_navigational_format?
  11. else
  12. session["devise.#{provider}_data"] = request.env['omniauth.auth']
  13. redirect_to new_user_registration_url
  14. end
  15. end
  16. end
  17. Devise.omniauth_configs.each_key do |provider|
  18. provides_callback_for provider
  19. end
  20. def after_sign_in_path_for(resource)
  21. if resource.email_verified?
  22. root_path
  23. else
  24. finish_signup_path
  25. end
  26. end
  27. end