Each time you edit a project with need authorization enabled, you have to re-enter the subversion password. I propose a solution for this: the cases insert, update and validate in subversion_nodeapi have to be changed. Case insert remains as was specified in case update. In the update case, everything (except the auth_password field) is updated with the database UPDATE command (instead of first deleting the entire row, and than inserting it again), and the auth_password field is only updated if a value was entered in the form. The validate case is a bit more complicated: if the user didn't enter a password, and the auth_password field for that project is empty (or the project does not yet exist), then an error message is shown requiring the user to enter a password. If the password field is left empty, and a value is already set in the auth_password field for that project, no error is shown, and the password remains unchanged. Here is the code:

      case 'insert':
        #print "<pre>" . var_export($node,1) . "</pre>";
        db_query('DELETE FROM {subversion_projects} WHERE nid = %d', $node->nid);

        if ($node->subversion_repository) {
          db_query("INSERT INTO {subversion_projects} (nid, rid, last_revision, trunk_path, tag_path, branch_path, need_auth, auth_username, auth_password ) VALUES (%d, %d, %d, '%s', '%s', '%s', '%d', '%s', '%s')",
            $node->nid, $node->subversion_repository, $node->last_revision, $node->trunk_path, $node->tag_path, $node->branch_path, !!$node->need_auth, $node->auth_username, $node->auth_password);
          foreach (array('trunk_path','tag_path','branch_path') as $field) {
            if (!$node->$field) { continue; }
            db_query("UPDATE {subversion_files} SET pid=%d WHERE rid=%d AND pid=0 AND file like '%s%%'", $node->rid, $node->nid, $node->$field); 
          }
        }
        break;
      case 'update':
        #print "<pre>" . var_export($node,1) . "</pre>";
        if ($node->subversion_repository) {
          db_query("UPDATE {subversion_projects} SET rid=%d, last_revision=%d, trunk_path='%s', tag_path='%s', branch_path='%s', need_auth=%d, auth_username='%s' WHERE nid = %d", $node->subversion_repository, $node->last_revision, $node->trunk_path, $node->tag_path, $node->branch_path, !!$node->need_auth, $node->auth_username, $node->nid);

          // update password (if any)
          if ($node->auth_password) {
		db_query("UPDATE {subversion_projects} SET auth_password = '%s' WHERE nid = %d", $node->auth_password, $node->nid);
          }

          foreach (array('trunk_path','tag_path','branch_path') as $field) {
            if (!$node->$field) { continue; }
            db_query("UPDATE {subversion_files} SET pid=%d WHERE rid=%d AND pid=0 AND file like '%s%%'", $node->rid, $node->nid, $node->$field); 
          }
        }
        break;
      case 'validate':
        if ($node->need_auth) {
          if (!$node->auth_username) {
            form_set_error('auth_username', t('Username is required if need authorization is enabled.'));
          }
          if (!$node->auth_password) {
            $pass = db_fetch_object(db_query('SELECT auth_password FROM {subversion_projects} WHERE nid = %d', $node->nid));
            if (!$pass or !$pass->auth_password) {
              form_set_error('auth_password', t('Password is required if need authorization is enabled.'));
            }
          }
        }
        break;

Comments

halkeye’s picture

Status: Needs review » Fixed
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.