Only show auth message if name changed

This commit is contained in:
Gabe Kangas 2023-01-30 11:19:50 -08:00
parent 47fbe1547c
commit 049a9d0080
No known key found for this signature in database
GPG key ID: 4345B2060657F330
2 changed files with 10 additions and 6 deletions

View file

@ -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, "")

View file

@ -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)