mirror of
https://github.com/h44z/wg-portal.git
synced 2025-06-28 01:07:03 +00:00
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
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if !s.useEncryption {
|
|
||||||
return fieldValue, nil // keep the original value
|
|
||||||
}
|
|
||||||
|
|
||||||
switch v := fieldValue.(type) {
|
switch v := fieldValue.(type) {
|
||||||
case string:
|
case string:
|
||||||
if v == "" {
|
if v == "" {
|
||||||
return "", nil // empty string, no need to encrypt
|
return "", nil // empty string, no need to encrypt
|
||||||
}
|
}
|
||||||
|
if !s.useEncryption {
|
||||||
|
return v, nil // keep the original value
|
||||||
|
}
|
||||||
encryptedString, err := EncryptAES256(v, s.keyPhrase)
|
encryptedString, err := EncryptAES256(v, s.keyPhrase)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -106,6 +105,9 @@ func (s GormEncryptedStringSerializer) Value(
|
|||||||
if v == "" {
|
if v == "" {
|
||||||
return "", nil // empty string, no need to encrypt
|
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)
|
encryptedString, err := EncryptAES256(string(v), s.keyPhrase)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user