Skip to content

Commit

Permalink
add basic auth without $project_path
Browse files Browse the repository at this point in the history
  • Loading branch information
shingara authored and defunkt committed Jul 9, 2010
1 parent 392366c commit e25cd35
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/cijoe/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ class Server < Sinatra::Base
redirect request.path
end

user, pass = Config.cijoe.user.to_s, Config.cijoe.pass.to_s
if user != '' && pass != ''
use Rack::Auth::Basic do |username, password|
[ username, password ] == [ user, pass ]
end
puts "Using HTTP basic auth"
end

helpers do
include Rack::Utils
Expand Down Expand Up @@ -76,6 +69,17 @@ def self.start(host, port, project_path)
CIJoe::Server.run! :host => host, :port => port
end

def self.project_path=(project_path)
user, pass = Config.cijoe(project_path).user.to_s, Config.cijoe(project_path).pass.to_s
if user != '' && pass != ''
use Rack::Auth::Basic do |username, password|
[ username, password ] == [ user, pass ]
end
puts "Using HTTP basic auth"
end
set :project_path, Proc.new{project_path}
end

def check_project
if options.project_path.nil? || !File.exists?(File.expand_path(options.project_path))
puts "Whoops! I need the path to a Git repo."
Expand Down

0 comments on commit e25cd35

Please sign in to comment.