fix(httpapi): fail CSV import on encryption error instead of storing empty passwords
This commit is contained in:
+10
-2
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user