mirror of
https://gitea.com/gitea/tea.git
synced 2025-04-10 19:46:10 +02:00
refresh oauth token in git cred helper func
This commit is contained in:
parent
c660c83e41
commit
6f768a3382
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user