refactor: imporve code style

This commit is contained in:
naiba
2024-06-23 16:15:08 +08:00
parent eee3225f3a
commit f75847d3d7
3 changed files with 33 additions and 37 deletions

View File

@@ -5,12 +5,13 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/naiba/nezha/pkg/oidc/cloudflare"
"net/http"
"net/url"
"strings"
"time"
"github.com/naiba/nezha/pkg/oidc/cloudflare"
"code.gitea.io/sdk/gitea"
"github.com/gin-gonic/gin"
GitHubAPI "github.com/google/go-github/v47/github"
@@ -192,15 +193,12 @@ func (oa *oauth2controller) callback(c *gin.Context) {
client = GitHubAPI.NewClient(oc)
}
var gu *GitHubAPI.User
if err == nil {
gu, _, err = client.Users.Get(ctx, "")
}
gu, _, err = client.Users.Get(ctx, "")
if err == nil {
user = model.NewUserFromGitHub(gu)
}
}
}
if err == nil && user.Login == "" {
err = errors.New("获取用户信息失败")
}