Sha256: 163c2dde455ae807f51bdfb3d04a3df4b2df517c643bc178a5cdca4eb55b6631

Contents?: true

Size: 327 Bytes

Versions: 6

Compression:

Stored size: 327 Bytes

Contents

# frozen_string_literal: true

module Itch
  # Mixin to raise exceptions when a request redirects to login page
  module RequireAuth
    def require_auth(page)
      raise AuthError, "User is not logged in" if page.uri.to_s == Itch::URL::LOGIN

      page
    end

    def with_login
      require_auth yield
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
itch_client-0.4.3 lib/itch/require_auth.rb
itch_client-0.4.2 lib/itch/require_auth.rb
itch_client-0.4.1 lib/itch/require_auth.rb
itch_client-0.4.0 lib/itch/require_auth.rb
itch_client-0.3.0 lib/itch/require_auth.rb
itch_client-0.2.0 lib/itch/require_auth.rb