Merge fix/trim-account-credentials: trim manual account creds
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MMHQTtnQtQqL8muAXHr9kd
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/vasyansk/imap-copier/internal/crypto"
|
"github.com/vasyansk/imap-copier/internal/crypto"
|
||||||
"github.com/vasyansk/imap-copier/internal/store"
|
"github.com/vasyansk/imap-copier/internal/store"
|
||||||
@@ -49,6 +50,12 @@ func (s *Server) handleCreateAccount(w http.ResponseWriter, r *http.Request) {
|
|||||||
http.Error(w, "bad json", http.StatusBadRequest)
|
http.Error(w, "bad json", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// Trim surrounding whitespace — pasted app passwords / logins often carry a
|
||||||
|
// stray trailing space or newline that the IMAP server rejects.
|
||||||
|
body.SrcLogin = strings.TrimSpace(body.SrcLogin)
|
||||||
|
body.SrcPass = strings.TrimSpace(body.SrcPass)
|
||||||
|
body.DstLogin = strings.TrimSpace(body.DstLogin)
|
||||||
|
body.DstPass = strings.TrimSpace(body.DstPass)
|
||||||
srcEnc, err := crypto.Encrypt(s.cfg.EncKey, []byte(body.SrcPass))
|
srcEnc, err := crypto.Encrypt(s.cfg.EncKey, []byte(body.SrcPass))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, "encrypt", http.StatusInternalServerError)
|
http.Error(w, "encrypt", http.StatusInternalServerError)
|
||||||
|
|||||||
Reference in New Issue
Block a user