Skip to content

Commit

Permalink
Fix /google_login/wait provisioning API and add some logs
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Feb 23, 2024
1 parent c806258 commit fec15f4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 0 additions & 4 deletions provisioning.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
7 changes: 7 additions & 0 deletions user.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,18 +478,25 @@ 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()
}
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
}
}()
Expand Down

0 comments on commit fec15f4

Please sign in to comment.