fix(httpapi): fail CSV import on encryption error instead of storing empty passwords

This commit is contained in:
2026-07-01 18:33:09 +07:00
parent bb83bbd989
commit 0bd4ba37e3
2 changed files with 38 additions and 2 deletions
+10 -2
View File
@@ -29,8 +29,16 @@ func (s *Server) handleImportCSV(w http.ResponseWriter, r *http.Request) {
return
}
for _, row := range rows {
srcEnc, _ := crypto.Encrypt(s.cfg.EncKey, []byte(row.SrcPass))
dstEnc, _ := crypto.Encrypt(s.cfg.EncKey, []byte(row.DstPass))
srcEnc, err := crypto.Encrypt(s.cfg.EncKey, []byte(row.SrcPass))
if err != nil {
http.Error(w, "encrypt", http.StatusInternalServerError)
return
}
dstEnc, err := crypto.Encrypt(s.cfg.EncKey, []byte(row.DstPass))
if err != nil {
http.Error(w, "encrypt", http.StatusInternalServerError)
return
}
if _, err := s.store.CreateAccount(r.Context(), store.Account{
TaskID: taskID, SrcLogin: row.SrcLogin, SrcPassEnc: srcEnc,
DstLogin: row.DstLogin, DstPassEnc: dstEnc,