ref: refs/heads/master
commit 08a7252778b44604c2ea1cbaf045e8eab3af9cf3
Author: Duncan Mac-Vicar P
Date: Wed Jul 15 11:31:13 2009 +0200
make sure everything is a URI
---
webclient/app/controllers/sessions_controller.rb | 2 +-
webclient/app/models/account.rb | 24 ++++++++++++---------
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/webclient/app/controllers/sessions_controller.rb b/webclient/app/controllers/sessions_controller.rb
index 9dc5cd4..4514189 100644
--- a/webclient/app/controllers/sessions_controller.rb
+++ b/webclient/app/controllers/sessions_controller.rb
@@ -63,7 +63,7 @@ class SessionsController < ApplicationController
begin
self.current_account, auth_token = Account.authenticate(params[:login],
params[:password],
- host.url)
+ host.uri)
# error handling when login to the service is pretty
# important to get meaningful error messages to the user
rescue Errno::ECONNREFUSED => e
diff --git a/webclient/app/models/account.rb b/webclient/app/models/account.rb
index 92cbb14..638c2d1 100644
--- a/webclient/app/models/account.rb
+++ b/webclient/app/models/account.rb
@@ -24,26 +24,30 @@ class Account < ActiveRecord::Base
#
# Will raise unless uri is a valid uri
#
- def self.authenticate(login, passwd, host)
- # Ensure that we really have a uri
- # else ActiveResource will raise an exception
- uri = URI.parse(host.to_s) rescue host.to_s
+ def self.authenticate(login, passwd, uri_s)
+ # host is just a hostname, and we want to set the
+ # HTTP client REST proxy URL to that host, so we need
+ # to add http
+ #
+ # in the future, if we use other protocols via a client
+ # proxy, we need to set the right url there too
+
+ # Ensure that we really have a http/https uri
+ uri = URI.parse(uri_s.to_s)
+
unless uri.is_a?(URI::HTTP) || uri.is_a?(URI::HTTPS)
- # FIXME, should be https
- uri = URI.parse "http://#{uri}"
- raise "Invalid uri" unless uri.is_a? URI::HTTP
+ raise "service should be a http or https URI"
end
- host = uri.to_s #set fixed host
# set default site url for all YaST service based resources
- YaST::ServiceResource::Session.site = host
+ YaST::ServiceResource::Session.site = uri
YaST::ServiceResource::Session.login = login
YaST::ServiceResource::Base.password = ""
YaST::ServiceResource::Session.auth_token = ""
# the above will obsolete this
- YaST::ServiceResource::Base.site = host
+ YaST::ServiceResource::Base.site = uri
# create a login resource
ret = YaST::ServiceResource::Login.create(:login => login, :password =>passwd, :remember_me => true)
logger.debug ret.inspect
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org