From e1ee91ef0915701c702ec2b7428ec14e70577c71 Mon Sep 17 00:00:00 2001
From: Kyle Browning <kylebrowning@me.com>
Date: Tue, 22 Mar 2011 10:42:30 -0700
Subject: [PATCH] [#1036758] cant remove auth

---
 services.admin.inc |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/services.admin.inc b/services.admin.inc
index 21303a2..a9b5025 100644
--- a/services.admin.inc
+++ b/services.admin.inc
@@ -318,11 +318,16 @@ function services_edit_form_endpoint_submit($form, &$form_state) {
   $auth = array();
   if (isset($form_state['values']['authentication'])) {
     foreach (array_keys($form_state['values']['authentication']) as $module) {
-      if (isset($endpoint->authentication[$module])) {
-        $auth[$module] = $endpoint->authentication[$module];
-      }
-      else {
-        $auth[$module] = array();
+      //if module's checkbox is checked, add to empty
+      if ( $module == $form_state['input']['authentication'][$module]) {
+        //if new entry
+        if (array_key_exists($module, $endpoint->authentication)) {
+          $auth[$module] = $endpoint->authentication[$module];
+        } 
+        else{
+          $auth[$module] = array();
+          $form_state['redirect'] = 'admin/config/services/services/' . $endpoint->name . '/authentication';
+        }
       }
     }
   }
@@ -337,7 +342,7 @@ function services_edit_form_endpoint_submit($form, &$form_state) {
   else {
     drupal_set_message(t('Your changes have been saved.'));
     services_endpoint_save($endpoint);
-    $form_state['redirect'] = 'admin/config/services/services';
+    if( empty($form_state['redirect']) ) $form_state['redirect'] = 'admin/config/services/services';
   }
 }
 
-- 
1.7.3.4

