chore: sync with gin-template

This commit is contained in:
JustSong
2022-11-22 11:04:06 +08:00
parent 8247192977
commit 5913266969
41 changed files with 813 additions and 490 deletions

View File

@@ -107,16 +107,24 @@ func GitHubOAuth(c *gin.Context) {
if model.IsGitHubIdAlreadyTaken(user.GitHubId) {
user.FillUserByGitHubId()
} else {
user.Username = "github_" + strconv.Itoa(model.GetMaxUserId()+1)
user.DisplayName = githubUser.Name
user.Email = githubUser.Email
user.Role = common.RoleCommonUser
user.Status = common.UserStatusEnabled
if common.RegisterEnabled {
user.Username = "github_" + strconv.Itoa(model.GetMaxUserId()+1)
user.DisplayName = githubUser.Name
user.Email = githubUser.Email
user.Role = common.RoleCommonUser
user.Status = common.UserStatusEnabled
if err := user.Insert(); err != nil {
if err := user.Insert(); err != nil {
c.JSON(http.StatusOK, gin.H{
"success": false,
"message": err.Error(),
})
return
}
} else {
c.JSON(http.StatusOK, gin.H{
"success": false,
"message": err.Error(),
"message": "管理员关闭了新用户注册",
})
return
}