]> andersk Git - moira.git/commitdiff
A user may have both a deleted account and a status 8 account, so we
authorzacheiss <zacheiss>
Wed, 28 May 2003 20:18:59 +0000 (20:18 +0000)
committerzacheiss <zacheiss>
Wed, 28 May 2003 20:18:59 +0000 (20:18 +0000)
need to be a bit more clever than using ORDER BY to find the best choice
of account.

reg_svr/reg_svr.pc

index a293c3b9ab9762e523f81730d2498351b721f15c..acb65068ff6e7bc165cb693278c42a2fd7c46fcc 100644 (file)
@@ -301,7 +301,7 @@ void RIFO(reg_client *rc, int argc, char **argv)
   char middle[USERS_MIDDLE_SIZE], last[USERS_LAST_SIZE];
   char fullname[USERS_FIRST_SIZE + USERS_MIDDLE_SIZE + USERS_LAST_SIZE];
   char class[USERS_TYPE_SIZE], pin[USERS_PIN_SIZE];
-  int uid, status, secure, sqlstatus;
+  int uid, status, secure, sqlstatus, count;
   EXEC SQL END DECLARE SECTION;
 
   if (rc->uid || argc != 4)
@@ -315,6 +315,8 @@ void RIFO(reg_client *rc, int argc, char **argv)
   ulast = argv[2];
   id = argv[3];
 
+  EXEC SQL SELECT count(login) INTO :count FROM users WHERE clearid = :id;
+
   /* "ORDER BY status" so that if there's both a matching state 0 entry
      and a matching state 3 entry, we'll get the former. */
   EXEC SQL DECLARE csr_id CURSOR FOR
@@ -334,6 +336,14 @@ void RIFO(reg_client *rc, int argc, char **argv)
       strtrim(class);
       strtrim(pin);
 
+      /* It's possible they have both a deleted account and a status 8
+       * account.  We can't compensate for that in the ORDER BY clause
+       * above, so check here.  If they have more than one entry and the
+       * first one we get is deleted, skip it.
+       */
+      if (status == US_DELETED && count > 1)
+       continue;
+
       /* Check names, allowing for the possibility that Moira and the
         user might have them split up differently. eg, Mary/Ann/Singleton
         vs. Mary Ann/Singleton. */
@@ -501,10 +511,8 @@ void SPIN(reg_client *rc, int argc, char **argv)
       return;
     }
 
-  /* "ORDER BY status" so that if there's both a matching state 0 entry
-     and a matching state 3 entry, we'll get the former. */
   EXEC SQL SELECT pin INTO :pin FROM users WHERE clearid = :rc->id
-    ORDER BY status;
+    AND status = :rc->user_status;
   strtrim(pin);
   if (strcmp(argv[0], pin) != 0)
     {
This page took 0.040508 seconds and 5 git commands to generate.