Sha256: b05278882adf4e7cfbd4a8e3d77965de8a4c98e6d3aed6a1f6ae7660f9e1eff1

Contents?: true

Size: 600 Bytes

Versions: 2

Compression:

Stored size: 600 Bytes

Contents

require 'omniauth-github'

module OmniAuth
  module Strategies
    class GitHubTeamMember < OmniAuth::Strategies::GitHub
      credentials do
        { 'team_member?' => github_team_member?(team_id) }
      end

      def github_team_member?(id)
        team_members = access_token.get("/teams/#{id}/members").parsed
        !!team_members.detect { |member| member['login'] == raw_info['login'] }
      rescue ::OAuth2::Error
        false
      end

      def team_id
        ENV["GITHUB_TEAM_ID"]
      end
    end
  end
end

OmniAuth.config.add_camelization "githubteammember", "GitHubTeamMember"

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
omniauth-github-team-member-1.0.1 lib/omniauth/strategies/github_team_member.rb
omniauth-github-team-member-1.0.0 lib/omniauth/strategies/github_team_member.rb