Sha256: 013741e54f25ffe009c61f7087c4c88704667eea7cb67dbfb4016ed6a8bf6cf9

Contents?: true

Size: 1.1 KB

Versions: 16

Compression:

Stored size: 1.1 KB

Contents

module GraphqlDevise
  module Resolvers
    class ConfirmAccount < Base
      argument :confirmation_token, String, required: true
      argument :redirect_url,       String, required: true

      def resolve(confirmation_token:, redirect_url:)
        resource = resource_class.confirm_by_token(confirmation_token)

        if resource.errors.empty?
          yield resource if block_given?

          redirect_header_options = { account_confirmation_success: true }

          redirect_to_link = if controller.signed_in?(resource_name)
            signed_in_resource.build_auth_url(
              redirect_url,
              redirect_headers(
                client_and_token(controller.signed_in_resource.create_token),
                redirect_header_options
              )
            )
          else
            DeviseTokenAuth::Url.generate(redirect_url, redirect_header_options)
          end

          controller.redirect_to(redirect_to_link)
          { authenticatable: resource }
        else
          raise_user_error(I18n.t('graphql_devise.confirmations.invalid_token'))
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
graphql_devise-0.12.3 lib/graphql_devise/resolvers/confirm_account.rb
graphql_devise-0.12.2 lib/graphql_devise/resolvers/confirm_account.rb
graphql_devise-0.12.1 lib/graphql_devise/resolvers/confirm_account.rb
graphql_devise-0.12.0 lib/graphql_devise/resolvers/confirm_account.rb
graphql_devise-0.11.4 lib/graphql_devise/resolvers/confirm_account.rb
graphql_devise-0.11.3 lib/graphql_devise/resolvers/confirm_account.rb
graphql_devise-0.11.2 lib/graphql_devise/resolvers/confirm_account.rb
graphql_devise-0.11.1 lib/graphql_devise/resolvers/confirm_account.rb
graphql_devise-0.11.0 lib/graphql_devise/resolvers/confirm_account.rb
graphql_devise-0.10.1 app/graphql/graphql_devise/resolvers/confirm_account.rb
graphql_devise-0.10.0 app/graphql/graphql_devise/resolvers/confirm_account.rb
graphql_devise-0.9.2 app/graphql/graphql_devise/resolvers/confirm_account.rb
graphql_devise-0.9.1 app/graphql/graphql_devise/resolvers/confirm_account.rb
graphql_devise-0.9.0 app/graphql/graphql_devise/resolvers/confirm_account.rb
graphql_devise-0.8.1 app/graphql/graphql_devise/resolvers/confirm_account.rb
graphql_devise-0.8.0 app/graphql/graphql_devise/resolvers/confirm_account.rb