On 01/28/2011 09:16 AM, mtaylor(a)redhat.com wrote:
From: Martyn Taylor<mtaylor(a)redhat.com>
---
.../controllers/resources/instances_controller.rb | 28 +++++++++++++++++++-
src/config/routes.rb | 5 +++-
2 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/src/app/controllers/resources/instances_controller.rb
b/src/app/controllers/resources/instances_controller.rb
index 9482a8d..5f2ccf8 100644
--- a/src/app/controllers/resources/instances_controller.rb
+++ b/src/app/controllers/resources/instances_controller.rb
@@ -1,5 +1,5 @@
class Resources::InstancesController< ApplicationController
- before_filter :require_user
+ before_filter :require_user, :except => [:can_start, :can_create]
I think in
this case we do want to require user -- but we need to
redefine require_user so that it handles API calls separately. We should
still get the user from the request, but the user/session handling will
be different for the API.
I know we haven't really worked out the auth bits here, so perhaps as a
first pass we'll have condor pass user_id=... into the URL query string
and then have require_user (for api calls only) set @current_user based
on the passed-in ID. If we can't do even this for now, then we should
disable auth checking _within_ require_user for api calls -- that way
there's only one place to fix it up once we solve api auth.
before_filter :load_instance, :only => [:show,
:remove_failed, :key, :stop]
before_filter :set_view_vars, :only => [:show, :index]
@@ -128,6 +128,32 @@ class Resources::InstancesController< ApplicationController
redirect_to resources_instances_path
end
+ def can_create
+ begin
+ cloud_account = CloudAccount.find(params[:cloud_account_id])
+ instance = Instance.find(params[:instance_id])
If this is on the instances
controller, shouldn't this just be
params[:id] ? I'm not sure if this is still true with multiple IDs here,
but to be consistent with the rest of the controllers, current object
for the current controller is usually just passed as :id
I haven't yet actually run through the code and tested it yet, but I'll
do that tomorrow (after any subsequent patches if you have any quick
solutions to the require_user issues)
Scott