修复git、微信等用户注册不会创建默认令牌问题
修复git、微信等用户注册不会创建默认令牌问题
This commit is contained in:
parent
9321427c6e
commit
a6f7a53b02
@ -6,6 +6,7 @@ import (
|
|||||||
"github.com/songquanpeng/one-api/common"
|
"github.com/songquanpeng/one-api/common"
|
||||||
"github.com/songquanpeng/one-api/common/blacklist"
|
"github.com/songquanpeng/one-api/common/blacklist"
|
||||||
"github.com/songquanpeng/one-api/common/config"
|
"github.com/songquanpeng/one-api/common/config"
|
||||||
|
"github.com/songquanpeng/one-api/common/helper"
|
||||||
"github.com/songquanpeng/one-api/common/logger"
|
"github.com/songquanpeng/one-api/common/logger"
|
||||||
"github.com/songquanpeng/one-api/common/random"
|
"github.com/songquanpeng/one-api/common/random"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
@ -140,6 +141,21 @@ func (user *User) Insert(inviterId int) error {
|
|||||||
RecordLog(inviterId, LogTypeSystem, fmt.Sprintf("邀请用户赠送 %s", common.LogQuota(config.QuotaForInviter)))
|
RecordLog(inviterId, LogTypeSystem, fmt.Sprintf("邀请用户赠送 %s", common.LogQuota(config.QuotaForInviter)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 创建默认令牌
|
||||||
|
cleanToken := Token{
|
||||||
|
UserId: user.Id,
|
||||||
|
Name: "default",
|
||||||
|
Key: random.GenerateKey(),
|
||||||
|
CreatedTime: helper.GetTimestamp(),
|
||||||
|
AccessedTime: helper.GetTimestamp(),
|
||||||
|
ExpiredTime: -1,
|
||||||
|
RemainQuota: -1,
|
||||||
|
UnlimitedQuota: true,
|
||||||
|
}
|
||||||
|
result.Error = cleanToken.Insert()
|
||||||
|
if result.Error != nil {
|
||||||
|
return result.Error
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user