Report failed bank connections and stop resurrecting deleted accounts
Three defects made new connections silently vanish while removed accounts returned: - A single shared account the journal cannot represent (securities or card entries without IBAN, stable identification or currency) aborted the entire consent. Usable accounts are now linked and the rest counted and reported. - A consent that linked nothing was stored, redirected as success and later reaped by session recovery. It now fails with the reason. - Callback failures rendered a bare JSON error page and were never logged. They now log and redirect into the app with the reason shown. - Deleting an account left its session binding, so the next connect or sync recovered the binding and re-added the account. Account deletion now releases bindings, consents and cursors before committing.
This commit is contained in:
@@ -6,10 +6,12 @@ import (
|
||||
"errors"
|
||||
"io"
|
||||
"io/fs"
|
||||
"log"
|
||||
"mime"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -304,7 +306,7 @@ func (s *Server) manage(w http.ResponseWriter, r *http.Request) {
|
||||
if !decode(w, r, &b) {
|
||||
return
|
||||
}
|
||||
v, e := s.app.Mutate(r.Context(), b.Revision, func(d *domain.Dataset) error { return app.Manage(d, b.Entity, b.Action, b.ID, b.TargetID) })
|
||||
v, e := s.app.ManageRegistry(r.Context(), b.Revision, b.Entity, b.Action, b.ID, b.TargetID)
|
||||
respond(w, v, e)
|
||||
}
|
||||
func (s *Server) importCSV(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -410,12 +412,19 @@ func (s *Server) authorize(w http.ResponseWriter, r *http.Request) {
|
||||
respond(w, map[string]string{"url": v}, e)
|
||||
}
|
||||
func (s *Server) callback(w http.ResponseWriter, r *http.Request) {
|
||||
e := s.app.Callback(r.Context(), r.URL.Query().Get("code"), r.URL.Query().Get("state"))
|
||||
unlinkable, e := s.app.Callback(r.Context(), r.URL.Query().Get("code"), r.URL.Query().Get("state"))
|
||||
if e != nil {
|
||||
respond(w, nil, e)
|
||||
// Callback errors are locally generated and sanitized. Landing on the
|
||||
// app with the reason visible beats a bare JSON error page.
|
||||
log.Printf("bank connection callback failed: %v", e)
|
||||
http.Redirect(w, r, "/?connect_error="+url.QueryEscape(e.Error()), http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
http.Redirect(w, r, "/?connected=1", http.StatusSeeOther)
|
||||
target := "/?connected=1"
|
||||
if unlinkable > 0 {
|
||||
target += "&unlinkable=" + strconv.Itoa(unlinkable)
|
||||
}
|
||||
http.Redirect(w, r, target, http.StatusSeeOther)
|
||||
}
|
||||
func (s *Server) preview(w http.ResponseWriter, r *http.Request) {
|
||||
var b app.PreviewRequest
|
||||
|
||||
Reference in New Issue
Block a user