Przeglądaj źródła

处理导入数据时手机号码加密两次的问题

zhou.xiaoning 2 lat temu
rodzic
commit
2c5be16709
1 zmienionych plików z 8 dodań i 1 usunięć
  1. 8 1
      models/account.go

+ 8 - 1
models/account.go

@@ -704,7 +704,14 @@ func GetUserInfo(userID int) (*Userinfo, error) {
 	if len(userInfo.Mobile) > 0 {
 		if s1, err := hex.DecodeString(userInfo.Mobile); err == nil { // hex -> []byte
 			if s2, err := utils.AESDecrypt(s1, key); err == nil {
-				userInfo.Mobile2 = string(s2)
+				// 临时操作 - 解决导入数据手机号码被加密两次的问题
+				if len(userInfo.Mobile) >= 40 {
+					if s3, err := utils.AESDecrypt(s2, key); err == nil {
+						userInfo.Mobile2 = string(s3)
+					}
+				} else {
+					userInfo.Mobile2 = string(s2)
+				}
 			}
 		}
 	}