Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
11c9acd5
authored
Sep 17, 2024
by
CalciumIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 初始令牌
parent
48be9d7e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
12 deletions
+4
-12
controller/user.go
+4
-12
No files found.
controller/user.go
View file @
11c9acd5
...
...
@@ -187,7 +187,7 @@ func Register(c *gin.Context) {
})
return
}
// 获取插入后的用户ID
var
insertedUser
model
.
User
if
err
:=
model
.
DB
.
Where
(
"username = ?"
,
cleanUser
.
Username
)
.
First
(
&
insertedUser
)
.
Error
;
err
!=
nil
{
...
...
@@ -199,23 +199,15 @@ func Register(c *gin.Context) {
}
// 生成默认令牌
if
constant
.
GenerateDefaultToken
{
var
insertedUser
model
.
User
if
err
:=
model
.
DB
.
Where
(
"username = ?"
,
cleanUser
.
Username
)
.
First
(
&
insertedUser
)
.
Error
;
err
!=
nil
{
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"success"
:
false
,
"message"
:
"用户注册失败或用户ID获取失败"
,
})
return
}
// 生成默认令牌
token
:=
model
.
Token
{
UserId
:
insertedUser
.
Id
,
// 使用插入后的用户ID
Name
:
cleanUser
.
Username
+
"的初始令牌"
,
Name
:
cleanUser
.
Username
+
"的初始令牌"
,
Key
:
common
.
GenerateKey
(),
CreatedTime
:
common
.
GetTimestamp
(),
AccessedTime
:
common
.
GetTimestamp
(),
ExpiredTime
:
-
1
,
// 永不过期
RemainQuota
:
500000
,
// 示例额度
ExpiredTime
:
-
1
,
// 永不过期
RemainQuota
:
500000
,
// 示例额度
UnlimitedQuota
:
true
,
ModelLimitsEnabled
:
false
,
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment