mirror of
https://github.com/h44z/wg-portal.git
synced 2025-10-06 08:26:17 +00:00
Compare commits
1 Commits
v2.0.0-rc.
...
v2.0.0-rc.
Author | SHA1 | Date | |
---|---|---|---|
|
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
|
||||||
|
Reference in New Issue
Block a user