lib/sinatra/auth/github.rb in sinatra_auth_github-0.1.4 vs lib/sinatra/auth/github.rb in sinatra_auth_github-0.1.5

- old
+ new

@@ -3,11 +3,11 @@ require 'rest_client' module Sinatra module Auth module Github - VERSION = "0.1.2" + VERSION = "0.1.5" # Simple way to serve an image early in the stack and not get blocked by # application level before filters class AccessDenied < Sinatra::Base enable :raise_errors @@ -77,11 +77,11 @@ # path - the path on api.github.com to hit # # Returns a parsed JSON response # # Examples - # github_raw_request("/user") + # github_request("/user") # # => { 'login' => 'atmos', ... } def github_request(path) JSON.parse(github_raw_request(path)) end @@ -99,11 +99,11 @@ # See if the user is a member of the named organization # # name - the organization name # - # Returns: true if the uesr has access, false otherwise + # Returns: true if the user has access, false otherwise def github_organization_access?(name) orgs = github_request("orgs/#{name}/members") orgs.map { |org| org["login"] }.include?(github_user.login) rescue RestClient::Forbidden, RestClient::Unauthorized, RestClient::ResourceNotFound => e false @@ -111,11 +111,11 @@ # See if the user is a member of the team id # # team_id - the team's id # - # Returns: true if the uesr has access, false otherwise + # Returns: true if the user has access, false otherwise def github_team_access?(team_id) members = github_request("teams/#{team_id}/members") members.map { |user| user["login"] }.include?(github_user.login) rescue RestClient::Forbidden, RestClient::Unauthorized, RestClient::ResourceNotFound => e false @@ -162,10 +162,10 @@ manager.default_strategies :github manager.failure_app = app.github_options[:failure_app] || BadAuthentication manager[:github_secret] = app.github_options[:secret] || ENV['GITHUB_CLIENT_SECRET'] - manager[:github_scopes] = app.github_options[:scopes] || 'email,offline_access' + manager[:github_scopes] = app.github_options[:scopes] || '' manager[:github_client_id] = app.github_options[:client_id] || ENV['GITHUB_CLIENT_ID'] manager[:github_callback_url] = app.github_options[:callback_url] || '/auth/github/callback' end app.helpers Helpers