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
3ed146f2
authored
Aug 04, 2025
by
Bliod-Cook
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: allow admin to restrict the minimum linuxdo trust level to register
parent
bb08de0b
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
2 deletions
+28
-2
common/constants.go
+1
-0
controller/linuxdo.go
+8
-0
controller/misc.go
+1
-0
model/option.go
+2
-0
web/src/components/settings/SystemSetting.js
+16
-2
No files found.
common/constants.go
View file @
3ed146f2
...
@@ -83,6 +83,7 @@ var GitHubClientId = ""
...
@@ -83,6 +83,7 @@ var GitHubClientId = ""
var
GitHubClientSecret
=
""
var
GitHubClientSecret
=
""
var
LinuxDOClientId
=
""
var
LinuxDOClientId
=
""
var
LinuxDOClientSecret
=
""
var
LinuxDOClientSecret
=
""
var
LinuxDOMinimumTrustLevel
=
0
var
WeChatServerAddress
=
""
var
WeChatServerAddress
=
""
var
WeChatServerToken
=
""
var
WeChatServerToken
=
""
...
...
controller/linuxdo.go
View file @
3ed146f2
...
@@ -220,6 +220,7 @@ func LinuxdoOAuth(c *gin.Context) {
...
@@ -220,6 +220,7 @@ func LinuxdoOAuth(c *gin.Context) {
}
}
}
else
{
}
else
{
if
common
.
RegisterEnabled
{
if
common
.
RegisterEnabled
{
if
linuxdoUser
.
TrustLevel
>=
common
.
LinuxDOMinimumTrustLevel
{
user
.
Username
=
"linuxdo_"
+
strconv
.
Itoa
(
model
.
GetMaxUserId
()
+
1
)
user
.
Username
=
"linuxdo_"
+
strconv
.
Itoa
(
model
.
GetMaxUserId
()
+
1
)
user
.
DisplayName
=
linuxdoUser
.
Name
user
.
DisplayName
=
linuxdoUser
.
Name
user
.
Role
=
common
.
RoleCommonUser
user
.
Role
=
common
.
RoleCommonUser
...
@@ -241,6 +242,13 @@ func LinuxdoOAuth(c *gin.Context) {
...
@@ -241,6 +242,13 @@ func LinuxdoOAuth(c *gin.Context) {
}
else
{
}
else
{
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"success"
:
false
,
"success"
:
false
,
"message"
:
"Linux DO 信任等级未达到管理员设置的最低信任等级"
,
})
return
}
}
else
{
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"success"
:
false
,
"message"
:
"管理员关闭了新用户注册"
,
"message"
:
"管理员关闭了新用户注册"
,
})
})
return
return
...
...
controller/misc.go
View file @
3ed146f2
...
@@ -48,6 +48,7 @@ func GetStatus(c *gin.Context) {
...
@@ -48,6 +48,7 @@ func GetStatus(c *gin.Context) {
"github_client_id"
:
common
.
GitHubClientId
,
"github_client_id"
:
common
.
GitHubClientId
,
"linuxdo_oauth"
:
common
.
LinuxDOOAuthEnabled
,
"linuxdo_oauth"
:
common
.
LinuxDOOAuthEnabled
,
"linuxdo_client_id"
:
common
.
LinuxDOClientId
,
"linuxdo_client_id"
:
common
.
LinuxDOClientId
,
"linuxdo_minimum_trust_level"
:
common
.
LinuxDOMinimumTrustLevel
,
"telegram_oauth"
:
common
.
TelegramOAuthEnabled
,
"telegram_oauth"
:
common
.
TelegramOAuthEnabled
,
"telegram_bot_name"
:
common
.
TelegramBotName
,
"telegram_bot_name"
:
common
.
TelegramBotName
,
"system_name"
:
common
.
SystemName
,
"system_name"
:
common
.
SystemName
,
...
...
model/option.go
View file @
3ed146f2
...
@@ -336,6 +336,8 @@ func updateOptionMap(key string, value string) (err error) {
...
@@ -336,6 +336,8 @@ func updateOptionMap(key string, value string) (err error) {
common
.
LinuxDOClientId
=
value
common
.
LinuxDOClientId
=
value
case
"LinuxDOClientSecret"
:
case
"LinuxDOClientSecret"
:
common
.
LinuxDOClientSecret
=
value
common
.
LinuxDOClientSecret
=
value
case
"LinuxDOMinimumTrustLevel"
:
common
.
LinuxDOMinimumTrustLevel
,
_
=
strconv
.
Atoi
(
value
)
case
"Footer"
:
case
"Footer"
:
common
.
Footer
=
value
common
.
Footer
=
value
case
"SystemName"
:
case
"SystemName"
:
...
...
web/src/components/settings/SystemSetting.js
View file @
3ed146f2
...
@@ -85,6 +85,7 @@ const SystemSetting = () => {
...
@@ -85,6 +85,7 @@ const SystemSetting = () => {
LinuxDOOAuthEnabled
:
''
,
LinuxDOOAuthEnabled
:
''
,
LinuxDOClientId
:
''
,
LinuxDOClientId
:
''
,
LinuxDOClientSecret
:
''
,
LinuxDOClientSecret
:
''
,
LinuxDOMinimumTrustLevel
:
''
,
ServerAddress
:
''
,
ServerAddress
:
''
,
});
});
...
@@ -472,6 +473,12 @@ const SystemSetting = () => {
...
@@ -472,6 +473,12 @@ const SystemSetting = () => {
value
:
inputs
.
LinuxDOClientSecret
,
value
:
inputs
.
LinuxDOClientSecret
,
});
});
}
}
if
(
originInputs
[
'LinuxDOMinimumTrustLevel'
]
!==
inputs
.
LinuxDOMinimumTrustLevel
)
{
options
.
push
({
key
:
'LinuxDOMinimumTrustLevel'
,
value
:
inputs
.
LinuxDOMinimumTrustLevel
,
});
}
if
(
options
.
length
>
0
)
{
if
(
options
.
length
>
0
)
{
await
updateOptions
(
options
);
await
updateOptions
(
options
);
...
@@ -916,14 +923,14 @@ const SystemSetting = () => {
...
@@ -916,14 +923,14 @@ const SystemSetting = () => {
<
Row
<
Row
gutter
=
{{
xs
:
8
,
sm
:
16
,
md
:
24
,
lg
:
24
,
xl
:
24
,
xxl
:
24
}}
gutter
=
{{
xs
:
8
,
sm
:
16
,
md
:
24
,
lg
:
24
,
xl
:
24
,
xxl
:
24
}}
>
>
<
Col
xs
=
{
24
}
sm
=
{
24
}
md
=
{
1
2
}
lg
=
{
12
}
xl
=
{
12
}
>
<
Col
xs
=
{
24
}
sm
=
{
24
}
md
=
{
1
0
}
lg
=
{
10
}
xl
=
{
10
}
>
<
Form
.
Input
<
Form
.
Input
field
=
'LinuxDOClientId'
field
=
'LinuxDOClientId'
label
=
{
t
(
'Linux DO Client ID'
)}
label
=
{
t
(
'Linux DO Client ID'
)}
placeholder
=
{
t
(
'输入你注册的 LinuxDO OAuth APP 的 ID'
)}
placeholder
=
{
t
(
'输入你注册的 LinuxDO OAuth APP 的 ID'
)}
/
>
/
>
<
/Col
>
<
/Col
>
<
Col
xs
=
{
24
}
sm
=
{
24
}
md
=
{
1
2
}
lg
=
{
12
}
xl
=
{
12
}
>
<
Col
xs
=
{
24
}
sm
=
{
24
}
md
=
{
1
0
}
lg
=
{
10
}
xl
=
{
10
}
>
<
Form
.
Input
<
Form
.
Input
field
=
'LinuxDOClientSecret'
field
=
'LinuxDOClientSecret'
label
=
{
t
(
'Linux DO Client Secret'
)}
label
=
{
t
(
'Linux DO Client Secret'
)}
...
@@ -931,6 +938,13 @@ const SystemSetting = () => {
...
@@ -931,6 +938,13 @@ const SystemSetting = () => {
placeholder
=
{
t
(
'敏感信息不会发送到前端显示'
)}
placeholder
=
{
t
(
'敏感信息不会发送到前端显示'
)}
/
>
/
>
<
/Col
>
<
/Col
>
<
Col
xs
=
{
24
}
sm
=
{
24
}
md
=
{
4
}
lg
=
{
4
}
xl
=
{
4
}
>
<
Form
.
Input
field
=
'LinuxDOMinimumTrustLevel'
label
=
'LinuxDO Minimum Trust Level'
placeholder
=
'允许注册的最低信任等级'
/>
<
/Col
>
<
/Row
>
<
/Row
>
<
Button
onClick
=
{
submitLinuxDOOAuth
}
>
<
Button
onClick
=
{
submitLinuxDOOAuth
}
>
{
t
(
'保存 Linux DO OAuth 设置'
)}
{
t
(
'保存 Linux DO OAuth 设置'
)}
...
...
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