From 049a9d0080f90c2476fb2126eacc625bf886c0b4 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Mon, 30 Jan 2023 11:19:50 -0800 Subject: [PATCH] Only show auth message if name changed --- controllers/auth/fediverse/fediverse.go | 8 +++++--- controllers/auth/indieauth/client.go | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/controllers/auth/fediverse/fediverse.go b/controllers/auth/fediverse/fediverse.go index 600bbc371..6f7002bff 100644 --- a/controllers/auth/fediverse/fediverse.go +++ b/controllers/auth/fediverse/fediverse.go @@ -79,9 +79,11 @@ func VerifyFediverseOTPRequest(w http.ResponseWriter, r *http.Request) { return } - loginMessage := fmt.Sprintf("**%s** is now authenticated as **%s**", authRegistration.UserDisplayName, u.DisplayName) - if err := chat.SendSystemAction(loginMessage, true); err != nil { - log.Errorln(err) + if authRegistration.UserDisplayName != u.DisplayName { + loginMessage := fmt.Sprintf("**%s** is now authenticated as **%s**", authRegistration.UserDisplayName, u.DisplayName) + if err := chat.SendSystemAction(loginMessage, true); err != nil { + log.Errorln(err) + } } controllers.WriteSimpleResponse(w, true, "") diff --git a/controllers/auth/indieauth/client.go b/controllers/auth/indieauth/client.go index 7b53ac4b8..8e7960c76 100644 --- a/controllers/auth/indieauth/client.go +++ b/controllers/auth/indieauth/client.go @@ -76,9 +76,11 @@ func HandleRedirect(w http.ResponseWriter, r *http.Request) { return } - loginMessage := fmt.Sprintf("**%s** is now authenticated as **%s**", request.DisplayName, u.DisplayName) - if err := chat.SendSystemAction(loginMessage, true); err != nil { - log.Errorln(err) + if request.DisplayName != u.DisplayName { + loginMessage := fmt.Sprintf("**%s** is now authenticated as **%s**", request.DisplayName, u.DisplayName) + if err := chat.SendSystemAction(loginMessage, true); err != nil { + log.Errorln(err) + } } http.Redirect(w, r, "/", http.StatusTemporaryRedirect)