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
262ece0d
authored
Feb 24, 2026
by
Seefs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: check oauthUser.Username length
parent
0427ddda
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
0 deletions
+5
-0
controller/oauth.go
+3
-0
model/user.go
+2
-0
No files found.
controller/oauth.go
View file @
262ece0d
...
@@ -240,9 +240,12 @@ func findOrCreateOAuthUser(c *gin.Context, provider oauth.Provider, oauthUser *o
...
@@ -240,9 +240,12 @@ func findOrCreateOAuthUser(c *gin.Context, provider oauth.Provider, oauthUser *o
if
oauthUser
.
Username
!=
""
{
if
oauthUser
.
Username
!=
""
{
if
exists
,
err
:=
model
.
CheckUserExistOrDeleted
(
oauthUser
.
Username
,
""
);
err
==
nil
&&
!
exists
{
if
exists
,
err
:=
model
.
CheckUserExistOrDeleted
(
oauthUser
.
Username
,
""
);
err
==
nil
&&
!
exists
{
// 防止索引退化
if
len
(
oauthUser
.
Username
)
<=
model
.
UserNameMaxLength
{
user
.
Username
=
oauthUser
.
Username
user
.
Username
=
oauthUser
.
Username
}
}
}
}
}
if
oauthUser
.
DisplayName
!=
""
{
if
oauthUser
.
DisplayName
!=
""
{
user
.
DisplayName
=
oauthUser
.
DisplayName
user
.
DisplayName
=
oauthUser
.
DisplayName
...
...
model/user.go
View file @
262ece0d
...
@@ -15,6 +15,8 @@ import (
...
@@ -15,6 +15,8 @@ import (
"gorm.io/gorm"
"gorm.io/gorm"
)
)
const
UserNameMaxLength
=
20
// User if you add sensitive fields, don't forget to clean them in setupLogin function.
// User if you add sensitive fields, don't forget to clean them in setupLogin function.
// Otherwise, the sensitive information will be saved on local storage in plain text!
// Otherwise, the sensitive information will be saved on local storage in plain text!
type
User
struct
{
type
User
struct
{
...
...
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