Fix /google_login/wait provisioning API and add some logs
This commit is contained in:
parent
c806258b82
commit
fec15f4bc8
2 changed files with 7 additions and 4 deletions
|
@ -356,10 +356,6 @@ func (prov *ProvisioningAPI) GoogleLoginWait(w http.ResponseWriter, r *http.Requ
|
|||
|
||||
log := prov.zlog.With().Str("user_id", user.MXID.String()).Str("endpoint", "login").Logger()
|
||||
|
||||
if user.IsLoggedIn() {
|
||||
jsonResponse(w, http.StatusOK, LoginResponse{Status: "success", ErrCode: "already logged in"})
|
||||
return
|
||||
}
|
||||
err := user.AsyncLoginGoogleWait()
|
||||
if err != nil {
|
||||
log.Err(err).Msg("Failed to start login")
|
||||
|
|
7
user.go
7
user.go
|
@ -478,6 +478,7 @@ func (user *User) AsyncLoginGoogleStart(cookies map[string]string) (outEmoji str
|
|||
var initialWait sync.WaitGroup
|
||||
initialWait.Add(1)
|
||||
callback := func(emoji string) {
|
||||
user.zlog.Info().Msg("Async google login got emoji")
|
||||
callbackDone = true
|
||||
outEmoji = emoji
|
||||
initialWait.Done()
|
||||
|
@ -485,11 +486,17 @@ func (user *User) AsyncLoginGoogleStart(cookies map[string]string) (outEmoji str
|
|||
go func() {
|
||||
err := user.LoginGoogle(cookies, callback)
|
||||
if !callbackDone {
|
||||
user.zlog.Err(err).Msg("Async google login failed before callback")
|
||||
initialWait.Done()
|
||||
outErr = err
|
||||
close(errChan)
|
||||
user.googleAsyncPairErrChan.Store(nil)
|
||||
} else {
|
||||
if err != nil {
|
||||
user.zlog.Err(err).Msg("Async google login failed after callback")
|
||||
} else {
|
||||
user.zlog.Info().Msg("Async google login succeeded")
|
||||
}
|
||||
errChan <- err
|
||||
}
|
||||
}()
|
||||
|
|
Loading…
Reference in a new issue