Module: Warden::GitHub::Rails::Routes

Defined in:
lib/warden/github/rails/routes.rb

Instance Method Summary collapse

Instance Method Details

#github_authenticate(scope = nil, options = {}, &routes_block) ⇒ Object

Enforces an authenticated GitHub user for the routes. If not authenticated, it initiates the OAuth flow.

Team and organization memberships can be checked by specifying a hash such as ‘team: ’foobar’‘ or `org: ’my_company’‘.



10
11
12
13
14
# File 'lib/warden/github/rails/routes.rb', line 10

def github_authenticate(scope=nil, options={}, &routes_block)
  github_constraint(scope, options, routes_block) do |warden, scope|
    warden.authenticate!(scope: scope)
  end
end

#github_authenticated(scope = nil, options = {}, &routes_block) ⇒ Object

The routes will only be visible to authenticated GitHub users. When not authenticated, it does not initiate the OAuth flow.

Team and organization memberships can be checked by specifying a hash such as ‘team: ’foobar’‘ or `org: ’my_company’‘.



21
22
23
24
25
# File 'lib/warden/github/rails/routes.rb', line 21

def github_authenticated(scope=nil, options={}, &routes_block)
  github_constraint(scope, options, routes_block) do |warden, scope|
    warden.authenticated?(scope: scope)
  end
end

#github_unauthenticated(scope = nil, options = {}, &routes_block) ⇒ Object

The routes will only be visible to all but authenticated GitHub users.

This constraint currently does not check for memberships since of its limited usage.



31
32
33
34
35
# File 'lib/warden/github/rails/routes.rb', line 31

def github_unauthenticated(scope=nil, options={}, &routes_block)
  github_constraint(scope, options, routes_block) do |warden, scope|
    not warden.authenticated?(scope: scope)
  end
end