Update github.go
This commit is contained in:
parent
d0e4687607
commit
80546d5e3c
@ -28,7 +28,7 @@ type GitHubUser struct {
|
||||
|
||||
func getGitHubUserInfoByCode(code string) (*GitHubUser, error) {
|
||||
if code == "" {
|
||||
return nil, errors.New("无效的参数")
|
||||
return nil, errors.New("invalid parameter")
|
||||
}
|
||||
values := map[string]string{"client_id": common.GitHubClientId, "client_secret": common.GitHubClientSecret, "code": code}
|
||||
jsonData, err := json.Marshal(values)
|
||||
@ -47,7 +47,7 @@ func getGitHubUserInfoByCode(code string) (*GitHubUser, error) {
|
||||
res, err := client.Do(req)
|
||||
if err != nil {
|
||||
common.SysLog(err.Error())
|
||||
return nil, errors.New("无法连接至 GitHub 服务器,请稍后重试!")
|
||||
return nil, errors.New("Unable to connect to GitHub servers, please try again later!")
|
||||
}
|
||||
defer res.Body.Close()
|
||||
var oAuthResponse GitHubOAuthResponse
|
||||
@ -63,7 +63,7 @@ func getGitHubUserInfoByCode(code string) (*GitHubUser, error) {
|
||||
res2, err := client.Do(req)
|
||||
if err != nil {
|
||||
common.SysLog(err.Error())
|
||||
return nil, errors.New("无法连接至 GitHub 服务器,请稍后重试!")
|
||||
return nil, errors.New("Unable to connect to GitHub server, please try again later!")
|
||||
}
|
||||
defer res2.Body.Close()
|
||||
var githubUser GitHubUser
|
||||
@ -72,7 +72,7 @@ func getGitHubUserInfoByCode(code string) (*GitHubUser, error) {
|
||||
return nil, err
|
||||
}
|
||||
if githubUser.Login == "" {
|
||||
return nil, errors.New("返回值非法,用户字段为空,请稍后重试!")
|
||||
return nil, errors.New("ilegal return value, user field is empty, please try again later!")
|
||||
}
|
||||
return &githubUser, nil
|
||||
}
|
||||
@ -88,7 +88,7 @@ func GitHubOAuth(c *gin.Context) {
|
||||
if !common.GitHubOAuthEnabled {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": false,
|
||||
"message": "管理员未开启通过 GitHub 登录以及注册",
|
||||
"message": "The administrator has not enabled login and registration through GitHub",
|
||||
})
|
||||
return
|
||||
}
|
||||
@ -135,7 +135,7 @@ func GitHubOAuth(c *gin.Context) {
|
||||
} else {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": false,
|
||||
"message": "管理员关闭了新用户注册",
|
||||
"message": "Admin turned off new user registration",
|
||||
})
|
||||
return
|
||||
}
|
||||
@ -143,7 +143,7 @@ func GitHubOAuth(c *gin.Context) {
|
||||
|
||||
if user.Status != common.UserStatusEnabled {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"message": "用户已被封禁",
|
||||
"message": "User has been banned",
|
||||
"success": false,
|
||||
})
|
||||
return
|
||||
@ -155,7 +155,7 @@ func GitHubBind(c *gin.Context) {
|
||||
if !common.GitHubOAuthEnabled {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": false,
|
||||
"message": "管理员未开启通过 GitHub 登录以及注册",
|
||||
"message": "The administrator has not enabled login and registration through GitHub",
|
||||
})
|
||||
return
|
||||
}
|
||||
@ -174,7 +174,7 @@ func GitHubBind(c *gin.Context) {
|
||||
if model.IsGitHubIdAlreadyTaken(user.GitHubId) {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": false,
|
||||
"message": "该 GitHub 账户已被绑定",
|
||||
"message": "The GitHub account has been bound",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user