mirror of
https://gitea.com/gitea/tea.git
synced 2026-08-26 01:27:38 +02:00
fix(oauth): don't wait for the browser opener to exit (#1093)
Fixes `tea login add --oauth` hanging after the user authenticates in the browser. `xdg-open` (at least on Debian) runs the browser in the foreground, so it does not exit until the browser does. `open.Run` waits for it, so tea is blocked and doesn't get the oAuth callback from the browser. This only happens when `xdg-open` has to start the browser. With one already running, the new process hands off and exits immediately. `open.Start` launches the opener and returns. The test mocks `xdg-open` with a script that holds the foreground and fails if `openBrowser` waits on it. Reviewed-on: https://gitea.com/gitea/tea/pulls/1093 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: James Braid <jamesb@loreland.org>
This commit is contained in:
@@ -366,7 +366,9 @@ func startLocalServerAndOpenBrowser(authURL, expectedState string, opts *OAuthOp
|
||||
var openBrowser = func(url string) error {
|
||||
fmt.Printf("Please authorize the application by visiting this URL in your browser:\n%s\n", url)
|
||||
|
||||
return open.Run(url)
|
||||
// Don't wait for the opener to exit, so a browser that holds the
|
||||
// foreground can't block the wait for the callback.
|
||||
return open.Start(url)
|
||||
}
|
||||
|
||||
// createLoginFromToken creates a login entry using the obtained access token
|
||||
|
||||
Reference in New Issue
Block a user