mirror of
				https://github.com/optim-enterprises-bv/databunker.git
				synced 2025-10-31 01:47:57 +00:00 
			
		
		
		
	rename email
This commit is contained in:
		| @@ -66,3 +66,7 @@ func (e mainEnv) pluginUserLookup(email string) { | ||||
| 	// not implemented | ||||
| } | ||||
|  | ||||
| func (dbobj dbcon) GlobalUserChangeEmail(oldEmail string, newEmail string) { | ||||
|         // not implemented | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -138,6 +138,15 @@ func (dbobj dbcon) updateUserRecordDo(jsonDataPatch []byte, userTOKEN string, ev | ||||
| 	if err != nil { | ||||
| 		return nil, nil, false, err | ||||
| 	} | ||||
| 	var raw2 map[string]interface{} | ||||
|         err = json.Unmarshal(decrypted, &raw2) | ||||
|         if err != nil { | ||||
| 		return nil, nil, false, err | ||||
|         } | ||||
| 	oldEmail := "" | ||||
|         if _, ok := raw2["email"]; ok { | ||||
|           oldEmail = normalizeEmail(raw2["email"].(string)) | ||||
|         } | ||||
| 	// merge | ||||
| 	fmt.Printf("old json: %s\n", decrypted) | ||||
| 	fmt.Printf("json patch: %s\n", jsonDataPatch) | ||||
| @@ -157,6 +166,7 @@ func (dbobj dbcon) updateUserRecordDo(jsonDataPatch []byte, userTOKEN string, ev | ||||
| 	// create new user record | ||||
| 	bdoc := bson.M{} | ||||
| 	keys := []string{"login", "email", "phone"} | ||||
| 	newEmail := "" | ||||
| 	for _, idx := range keys { | ||||
| 		//fmt.Printf("Checking %s\n", idx) | ||||
| 		actionCode := 1 | ||||
| @@ -167,6 +177,7 @@ func (dbobj dbcon) updateUserRecordDo(jsonDataPatch []byte, userTOKEN string, ev | ||||
| 			if len(newIdxFinalValue) > 0 { | ||||
| 				if idx == "email" { | ||||
| 					newIdxFinalValue = normalizeEmail(newIdxFinalValue) | ||||
| 					newEmail = newIdxFinalValue | ||||
| 				} else if idx == "phone" { | ||||
| 					newIdxFinalValue = normalizePhone(newIdxFinalValue, conf.Sms.DefaultCountry) | ||||
| 				} | ||||
| @@ -219,6 +230,9 @@ func (dbobj dbcon) updateUserRecordDo(jsonDataPatch []byte, userTOKEN string, ev | ||||
| 	if err != nil { | ||||
| 		return nil, nil, false, err | ||||
| 	} | ||||
| 	if oldEmail != newEmail && len(oldEmail) > 0 && len(newEmail) > 0 { | ||||
| 		dbobj.GlobalUserChangeEmail(oldEmail, newEmail) | ||||
| 	} | ||||
| 	if event != nil { | ||||
| 		event.Before = encData0 | ||||
| 		event.After = encodedStr | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 root
					root