Continue auth when failed to open browser (#794)

When users login gitea on a headless server via ssh, xdg-open might not be installed on that machine. So tea may fail to open URL itself. In this case, users can use the other machine to open the URL for authentication.

Github CLI act like this, too.

Signed-off-by: Chen Linxuan <me@black-desk.cn>

Reviewed-on: https://gitea.com/gitea/tea/pulls/794
Reviewed-by: blumia <blumia@noreply.gitea.com>
Co-authored-by: Chen Linxuan <me@black-desk.cn>
Co-committed-by: Chen Linxuan <me@black-desk.cn>
This commit is contained in:
Chen Linxuan
2025-08-18 03:12:25 +00:00
committed by Lunny Xiao
parent 07ca1ba106
commit 8876fe3cb8

View File

@ -336,7 +336,7 @@ func startLocalServerAndOpenBrowser(authURL, expectedState string, opts OAuthOpt
// Open browser
fmt.Println("Opening browser for authorization...")
if err := openBrowser(authURL); err != nil {
return "", "", fmt.Errorf("failed to open browser: %s", err)
fmt.Println("Failed to open browser: ", err)
}
// Wait for code, error, or timeout