mirror of https://github.com/h44z/wg-portal.git
				
				
				
			fix gorm error if no encryption is used (#427)
This commit is contained in:
		
							parent
							
								
									020ebb64e7
								
							
						
					
					
						commit
						b4aa6f8ef3
					
				|  | @ -88,15 +88,14 @@ func (s GormEncryptedStringSerializer) Value( | |||
| 		return nil, nil | ||||
| 	} | ||||
| 
 | ||||
| 	if !s.useEncryption { | ||||
| 		return fieldValue, nil // keep the original value
 | ||||
| 	} | ||||
| 
 | ||||
| 	switch v := fieldValue.(type) { | ||||
| 	case string: | ||||
| 		if v == "" { | ||||
| 			return "", nil // empty string, no need to encrypt
 | ||||
| 		} | ||||
| 		if !s.useEncryption { | ||||
| 			return v, nil // keep the original value
 | ||||
| 		} | ||||
| 		encryptedString, err := EncryptAES256(v, s.keyPhrase) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
|  | @ -106,6 +105,9 @@ func (s GormEncryptedStringSerializer) Value( | |||
| 		if v == "" { | ||||
| 			return "", nil // empty string, no need to encrypt
 | ||||
| 		} | ||||
| 		if !s.useEncryption { | ||||
| 			return string(v), nil // keep the original value
 | ||||
| 		} | ||||
| 		encryptedString, err := EncryptAES256(string(v), s.keyPhrase) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue