mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-10 02:23:43 +08:00
Merge remote-tracking branch 'origin/upstream/main'
This commit is contained in:
@@ -12,8 +12,6 @@ import (
|
||||
"github.com/songquanpeng/one-api/common"
|
||||
"github.com/songquanpeng/one-api/common/config"
|
||||
"github.com/songquanpeng/one-api/common/ctxkey"
|
||||
"github.com/songquanpeng/one-api/common/helper"
|
||||
"github.com/songquanpeng/one-api/common/logger"
|
||||
"github.com/songquanpeng/one-api/common/random"
|
||||
"github.com/songquanpeng/one-api/model"
|
||||
)
|
||||
@@ -117,7 +115,6 @@ func Logout(c *gin.Context) {
|
||||
}
|
||||
|
||||
func Register(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
if !config.RegisterEnabled {
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"message": "管理员关闭了新用户注册",
|
||||
@@ -182,28 +179,6 @@ func Register(c *gin.Context) {
|
||||
})
|
||||
return
|
||||
}
|
||||
go func() {
|
||||
err := user.ValidateAndFill()
|
||||
if err != nil {
|
||||
logger.Errorf(ctx, "user.ValidateAndFill failed: %v", err)
|
||||
return
|
||||
}
|
||||
cleanToken := model.Token{
|
||||
UserId: user.Id,
|
||||
Name: "default",
|
||||
Key: random.GenerateKey(),
|
||||
CreatedTime: helper.GetTimestamp(),
|
||||
AccessedTime: helper.GetTimestamp(),
|
||||
ExpiredTime: -1,
|
||||
RemainQuota: -1,
|
||||
UnlimitedQuota: true,
|
||||
}
|
||||
err = cleanToken.Insert()
|
||||
if err != nil {
|
||||
logger.Errorf(ctx, "cleanToken.Insert failed: %v", err)
|
||||
return
|
||||
}
|
||||
}()
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"success": true,
|
||||
"message": "",
|
||||
|
||||
Reference in New Issue
Block a user