login/remoteauth: tolerate multiple attempts to cancel
This will otherwise panic.
This commit is contained in:
@@ -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()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user