检查用户!= null虽然用户已获得授权

时间:2016-08-25 07:09:26

标签: asp.net-mvc

这是关于asp.net mvc 5的问题。 在某些操作中,虽然用户已获得授权,但在通过其ID获取用户后,将检查用户是否为!= null。他们为什么要检查用户!= null?

DataP removeData(TableP table, const void* key) 
  { 
      TableP tableP = table; 
      int cell = table->hfun(key, table->size); 
      HashTable hashTable = table->hashTable; 
      /*  
       * See change in the following line: 
       * Before the change you were trying to assign type  
       * `HashSet` into type `HashTableSet*`, this will   
       */ 
      HashTableSet *setPtr = hashTable;                                                         
      int i = 0;         
      int j = 0;         
      int d = 1;         
      while(d < tableP->d)         
      {         
          for (; i < MAX_ROW_ELEMENTS; i++)     
          {     
              if (table->fcomp(setPtr->hashSet[i]->key, key) == 0) 
              { 
                  DataP dataP = setPtr->hashSet[i]->dataP;
                  setPtr->hashSet[i] = NULL;
                  table->freeKey((void*)key);
                  return dataP;
              } 
          }     
          setPtr *= 2;     
          i = 0;     
      }         
      return NULL;         
  }      

1 个答案:

答案 0 :(得分:0)

通过避免错误更新来维护数据质量和完整性,因为可能存在由于会话超时而导致用户的值为空或者可能故意将其置为空的情况。 这也是一项安全措施。