module Perkins::Auth::Github::Helpers
Public Instance Methods
# File lib/perkins/auth/github.rb, line 145 def _relative_url_for(path) request.script_name + path end
# File lib/perkins/auth/github.rb, line 43 def authenticate!(*args) warden.authenticate!(*args) end
# File lib/perkins/auth/github.rb, line 47 def authenticated?(*args) warden.authenticated?(*args) end
See if the user is a member of the named organization
name - the organization name
Returns: true if the user has access, false otherwise
# File lib/perkins/auth/github.rb, line 102 def github_organization_access?(name) github_user.organization_member?(name) end
Enforce user membership to the named organization if membership is publicized
name - the organization to test membership against
Returns an execution halt if the user is not a member of the named org
# File lib/perkins/auth/github.rb, line 130 def github_organization_authenticate!(name) authenticate! halt([401, "Unauthorized User"]) unless github_organization_access?(name) end
See if the user is a public member of the named organization
name - the organization name
Returns: true if the user is public access, false otherwise
# File lib/perkins/auth/github.rb, line 93 def github_public_organization_access?(name) github_user.publicized_organization_member?(name) end
Enforce user membership to the named organization
name - the organization to test membership against
Returns an execution halt if the user is not a member of the named org
# File lib/perkins/auth/github.rb, line 120 def github_public_organization_authenticate!(name) authenticate! halt([401, "Unauthorized User"]) unless github_public_organization_access?(name) end
Send a V3 API GET request to path
path - the path on api.github.com to hit
Returns a rest client response object
Examples
github_raw_request("/user") # => RestClient::Response
# File lib/perkins/auth/github.rb, line 71 def github_raw_request(path) github_user.github_raw_request(path) end
Send a V3 API GET request to path and parse the response body
path - the path on api.github.com to hit
Returns a parsed JSON response
Examples
github_request("/user") # => { 'login' => 'atmos', ... }
# File lib/perkins/auth/github.rb, line 84 def github_request(path) github_user.github_request(path) end
See if the user is a member of the team id
team_id - the team's id
Returns: true if the user has access, false otherwise
# File lib/perkins/auth/github.rb, line 111 def github_team_access?(team_id) github_user.team_member?(team_id) end
Enforce user membership to the team id
team_id - the team_id to test membership against
Returns an execution halt if the user is not a member of the team
# File lib/perkins/auth/github.rb, line 140 def github_team_authenticate!(team_id) authenticate! halt([401, "Unauthorized User"]) unless github_team_access?(team_id) end
The authenticated user object
Supports a variety of methods, name, full_name, email, etc
# File lib/perkins/auth/github.rb, line 58 def github_user warden.user end
# File lib/perkins/auth/github.rb, line 51 def logout! warden.logout end
# File lib/perkins/auth/github.rb, line 39 def warden env['warden'] end