Properly reset login in progress flag after google login
This commit is contained in:
parent
8eed8382cb
commit
7db7fdf20b
2 changed files with 13 additions and 4 deletions
|
@ -426,6 +426,14 @@ func (prov *ProvisioningAPI) Login(w http.ResponseWriter, r *http.Request) {
|
|||
})
|
||||
return
|
||||
}
|
||||
if errors.Is(err, ErrLoginInProgress) && ch == nil {
|
||||
log.Err(err).Msg("Tried to start QR login while non-QR login is in progress")
|
||||
jsonResponse(w, http.StatusBadRequest, Error{
|
||||
Error: "Non-QR login already in progress",
|
||||
ErrCode: "unknown",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
var item, prevItem qrChannelItem
|
||||
var hasItem bool
|
||||
|
|
9
user.go
9
user.go
|
@ -521,11 +521,14 @@ func (user *User) LoginGoogle(cookies map[string]string, emojiCallback func(stri
|
|||
} else if !user.loginInProgress.CompareAndSwap(false, true) {
|
||||
return ErrLoginInProgress
|
||||
}
|
||||
defer user.loginInProgress.Store(false)
|
||||
if user.Client != nil {
|
||||
user.unlockedDeleteConnection()
|
||||
}
|
||||
pairSuccessChan := make(chan struct{})
|
||||
user.pairSuccessChan = pairSuccessChan
|
||||
user.pairSuccessChan = make(chan struct{})
|
||||
defer func() {
|
||||
user.pairSuccessChan = nil
|
||||
}()
|
||||
authData := libgm.NewAuthData()
|
||||
authData.Cookies = cookies
|
||||
user.createClient(authData)
|
||||
|
@ -533,8 +536,6 @@ func (user *User) LoginGoogle(cookies map[string]string, emojiCallback func(stri
|
|||
err := user.Client.DoGaiaPairing(emojiCallback)
|
||||
if err != nil {
|
||||
user.unlockedDeleteConnection()
|
||||
user.pairSuccessChan = nil
|
||||
user.loginInProgress.Store(false)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
|
Loading…
Reference in a new issue