@@ -44,16 +44,16 @@ func (dbobj dbcon) createUserRecord(parsedData utils.UserJSONStruct, event *Audi
4444 // I use original md5(master_key) as a kind of salt here,
4545 // so no additional configuration field is needed here.
4646 if len (parsedData .LoginIdx ) > 0 {
47- bdoc ["loginidx" ] = utils .HashString (dbobj .hash , parsedData .LoginIdx )
47+ bdoc ["loginidx" ] = utils .HashString (dbobj .salt , parsedData .LoginIdx )
4848 }
4949 if len (parsedData .EmailIdx ) > 0 {
50- bdoc ["emailidx" ] = utils .HashString (dbobj .hash , parsedData .EmailIdx )
50+ bdoc ["emailidx" ] = utils .HashString (dbobj .salt , parsedData .EmailIdx )
5151 }
5252 if len (parsedData .PhoneIdx ) > 0 {
53- bdoc ["phoneidx" ] = utils .HashString (dbobj .hash , parsedData .PhoneIdx )
53+ bdoc ["phoneidx" ] = utils .HashString (dbobj .salt , parsedData .PhoneIdx )
5454 }
5555 if len (parsedData .CustomIdx ) > 0 {
56- bdoc ["customidx" ] = utils .HashString (dbobj .hash , parsedData .CustomIdx )
56+ bdoc ["customidx" ] = utils .HashString (dbobj .salt , parsedData .CustomIdx )
5757 }
5858 if event != nil {
5959 event .After = encodedStr
@@ -235,7 +235,7 @@ func (dbobj dbcon) updateUserRecordDo(jsonDataPatch []byte, userTOKEN string, ol
235235 }
236236 if idxOldValue , ok := oldUserBson [idx + "idx" ]; ok {
237237 if len (newIdxFinalValue ) > 0 && len (idxOldValue .(string )) >= 0 {
238- idxStringHashHex := utils .HashString (dbobj .hash , newIdxFinalValue )
238+ idxStringHashHex := utils .HashString (dbobj .salt , newIdxFinalValue )
239239 if idxStringHashHex == idxOldValue .(string ) {
240240 //log.Println("Index value NOT changed!")
241241 actionCode = 0
@@ -255,7 +255,7 @@ func (dbobj dbcon) updateUserRecordDo(jsonDataPatch []byte, userTOKEN string, ol
255255 return nil , nil , true , fmt .Errorf ("duplicate %s index" , idx )
256256 }
257257 //log.Printf("Adding index3? %s\n", raw[idx])
258- bdoc [idx + "idx" ] = utils .HashString (dbobj .hash , newIdxFinalValue )
258+ bdoc [idx + "idx" ] = utils .HashString (dbobj .salt , newIdxFinalValue )
259259 } else if len (newIdxFinalValue ) == 0 {
260260 bdel = append (bdel , idx + "idx" )
261261 }
@@ -314,7 +314,7 @@ func (dbobj dbcon) lookupUserRecordByIndex(indexName string, indexValue string,
314314 if indexName == "exptoken" {
315315 return dbobj .store .GetRecord (storage .TblName .Users , "exptoken" , indexValue )
316316 }
317- idxStringHashHex := utils .HashString (dbobj .hash , indexValue )
317+ idxStringHashHex := utils .HashString (dbobj .salt , indexValue )
318318 //log.Printf("Loading by %s, value: %s\n", indexName, indexValue)
319319 return dbobj .store .GetRecord (storage .TblName .Users , indexName + "idx" , idxStringHashHex )
320320}
0 commit comments