Allow fixing an account's credentials from a failed test
An imported account with a wrong password could only be deleted and re-added, which loses its folder mapping and its migration journal. Clicking either FAIL badge now opens a dialog for both logins and both passwords. Passwords are never sent to the browser, so the password fields start empty and an empty field keeps the stored ciphertext — one side can be corrected without retyping the other. Saving resets both test verdicts to unknown: they described the previous credentials, and the run gate requires a passing test on both sides, so the account cannot start on an unverified password. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -32,6 +32,21 @@ func (s *Store) CreateAccount(ctx context.Context, a Account) (int64, error) {
|
||||
return id, err
|
||||
}
|
||||
|
||||
// UpdateAccountCredentials replaces an account's logins and, when a new
|
||||
// ciphertext is supplied, its passwords; a nil password keeps the stored one so
|
||||
// the operator can fix only the side that failed. Both connection tests are
|
||||
// reset to "unknown" because the previous verdicts no longer describe these
|
||||
// credentials, which also forces a re-test before the account can run.
|
||||
func (s *Store) UpdateAccountCredentials(ctx context.Context, id int64, srcLogin, dstLogin string, srcPassEnc, dstPassEnc *string) error {
|
||||
_, err := s.Pool.Exec(ctx,
|
||||
`UPDATE accounts SET src_login=$2, dst_login=$3,
|
||||
src_pass_enc=COALESCE($4, src_pass_enc), dst_pass_enc=COALESCE($5, dst_pass_enc),
|
||||
test_src_status='unknown', test_dst_status='unknown', last_error=''
|
||||
WHERE id=$1`,
|
||||
id, srcLogin, dstLogin, srcPassEnc, dstPassEnc)
|
||||
return err
|
||||
}
|
||||
|
||||
// DeleteAccount removes one account (and its migrated_messages via ON DELETE CASCADE).
|
||||
func (s *Store) DeleteAccount(ctx context.Context, id int64) error {
|
||||
_, err := s.Pool.Exec(ctx, `DELETE FROM accounts WHERE id=$1`, id)
|
||||
|
||||
Reference in New Issue
Block a user