login/remoteauth: tolerate multiple attempts to cancel

This will otherwise panic.
This commit is contained in:
Skip R
2026-01-13 14:49:01 -08:00
parent e38998e68b
commit 3d59a0eb3f

View File

@@ -31,6 +31,7 @@ const LoginFlowIDRemoteAuth = "fi.mau.discord.login.remote_auth"
type DiscordRemoteAuthLogin struct { type DiscordRemoteAuthLogin struct {
*DiscordGenericLogin *DiscordGenericLogin
hasClosed bool
remoteAuthClient *remoteauth.Client remoteAuthClient *remoteauth.Client
qrChan chan string qrChan chan string
doneChan chan struct{} doneChan chan struct{}
@@ -125,6 +126,12 @@ func (dl *DiscordRemoteAuthLogin) finalizeSuccessfulLogin(ctx context.Context, u
} }
func (dl *DiscordRemoteAuthLogin) Cancel() { func (dl *DiscordRemoteAuthLogin) Cancel() {
// Tolerate multiple attempts to cancel.
if dl.hasClosed {
return
}
dl.hasClosed = true
dl.User.Log.Debug().Msg("Discord remoteauth cancelled") dl.User.Log.Debug().Msg("Discord remoteauth cancelled")
dl.DiscordGenericLogin.Cancel() dl.DiscordGenericLogin.Cancel()