diff --git a/internal/photos/models/account.go b/internal/photos/models/account.go index ffc45c1..2729136 100644 --- a/internal/photos/models/account.go +++ b/internal/photos/models/account.go @@ -18,8 +18,12 @@ type Account struct { } func (a *Account) BeforeCreate(tx *gorm.DB) error { + a.EncryptPassword() + return nil +} + +func (a *Account) EncryptPassword() { sha1 := crypto.SHA256.New() sha1.Write([]byte(a.Password)) a.EncryptedPassword = base64.StdEncoding.EncodeToString(sha1.Sum(nil)) - return nil }