mirror of
https://gitea.com/gitea/tea.git
synced 2025-09-09 13:22:54 +02:00
refresh oauth token in git cred helper func
This commit is contained in:
@ -10,7 +10,9 @@ import (
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/tea/modules/auth"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/task"
|
||||
"github.com/urfave/cli/v2"
|
||||
@ -102,6 +104,14 @@ var CmdLoginHelper = cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
if userConfig.TokenExpiry > 0 && time.Now().Unix() > userConfig.TokenExpiry {
|
||||
// Token is expired, refresh it
|
||||
err = auth.RefreshAccessToken(userConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
_, err = fmt.Fprintf(os.Stdout, "protocol=%s\nhost=%s\nusername=%s\npassword=%s\n", host.Scheme, host.Host, userConfig.User, userConfig.Token)
|
||||
if err != nil {
|
||||
return err
|
||||
|
Reference in New Issue
Block a user