Module: RailsAuthGithub::Helpers

Extended by:
ActiveSupport::Concern
Defined in:
lib/rails-auth-github/helpers.rb

Instance Method Summary collapse

Instance Method Details

#authenticate!(*args) ⇒ Object



16
17
18
# File 'lib/rails-auth-github/helpers.rb', line 16

def authenticate!(*args)
  warden.authenticate!(*args)
end

#authenticated?(*args) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/rails-auth-github/helpers.rb', line 20

def authenticated?(*args)
  warden.authenticated?(*args)
end

#github_organization_access?(name) ⇒ Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/rails-auth-github/helpers.rb', line 44

def github_organization_access?(name)
  github_user.organization_member?(name)
end

#github_organization_authenticate!(name) ⇒ Object



57
58
59
60
# File 'lib/rails-auth-github/helpers.rb', line 57

def github_organization_authenticate!(name)
  authenticate!
  raise RailsAuthGithub::Unauthorized unless github_organization_access?(name)
end

#github_public_organization_access?(name) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/rails-auth-github/helpers.rb', line 40

def github_public_organization_access?(name)
  github_user.publicized_organization_member?(name)
end

#github_public_organization_authenticate!(name) ⇒ Object



52
53
54
55
# File 'lib/rails-auth-github/helpers.rb', line 52

def github_public_organization_authenticate!(name)
  authenticate!
  raise RailsAuthGithub::Unauthorized unless github_public_organization_access?(name)
end

#github_raw_request(path) ⇒ Object



32
33
34
# File 'lib/rails-auth-github/helpers.rb', line 32

def github_raw_request(path)
  github_user.github_raw_request(path)
end

#github_request(path) ⇒ Object



36
37
38
# File 'lib/rails-auth-github/helpers.rb', line 36

def github_request(path)
  github_user.github_request(path)
end

#github_team_access?(team_id) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/rails-auth-github/helpers.rb', line 48

def github_team_access?(team_id)
  github_user.team_member?(team_id)
end

#github_team_authenticate!(team_id) ⇒ Object



62
63
64
65
# File 'lib/rails-auth-github/helpers.rb', line 62

def github_team_authenticate!(team_id)
  authenticate!
  raise RailsAuthGithub::Unauthorized unless github_team_access?(team_id)
end

#github_unauthorized_userObject



67
68
69
# File 'lib/rails-auth-github/helpers.rb', line 67

def github_unauthorized_user
  head 401
end

#github_userObject



28
29
30
# File 'lib/rails-auth-github/helpers.rb', line 28

def github_user
  warden.user
end

#logout!Object



24
25
26
# File 'lib/rails-auth-github/helpers.rb', line 24

def logout!
  warden.logout
end

#wardenObject



12
13
14
# File 'lib/rails-auth-github/helpers.rb', line 12

def warden
  request.env['warden']
end