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
a9d3c59e
authored
Mar 01, 2024
by
Ehco1996
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Telegram OAuth support
parent
c9496d1c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
26 deletions
+39
-26
common/constants.go
+1
-0
controller/misc.go
+2
-0
makefile
+4
-0
model/option.go
+5
-0
web/src/components/SystemSetting.js
+27
-26
No files found.
common/constants.go
View file @
a9d3c59e
...
...
@@ -45,6 +45,7 @@ var PasswordRegisterEnabled = true
var
EmailVerificationEnabled
=
false
var
GitHubOAuthEnabled
=
false
var
WeChatAuthEnabled
=
false
var
TelegramOAuthEnabled
=
false
var
TurnstileCheckEnabled
=
false
var
RegisterEnabled
=
true
...
...
controller/misc.go
View file @
a9d3c59e
...
...
@@ -20,6 +20,8 @@ func GetStatus(c *gin.Context) {
"email_verification"
:
common
.
EmailVerificationEnabled
,
"github_oauth"
:
common
.
GitHubOAuthEnabled
,
"github_client_id"
:
common
.
GitHubClientId
,
"telegram_oauth"
:
common
.
TelegramOAuthEnabled
,
"telegram_bot_name"
:
common
.
TelegramBotName
,
"system_name"
:
common
.
SystemName
,
"logo"
:
common
.
Logo
,
"footer_html"
:
common
.
Footer
,
...
...
makefile
View file @
a9d3c59e
...
...
@@ -5,6 +5,10 @@ BACKEND_DIR = .
all
:
start-frontend start-backend
build-frontend
:
@
echo
"Building frontend..."
@
cd
$(FRONTEND_DIR)
&&
npm install
&&
DISABLE_ESLINT_PLUGIN
=
'true'
REACT_APP_VERSION
=
$
(
cat
VERSION
)
npm run build npm run build
# 启动前端开发服务器
start-frontend
:
@
echo
"Starting frontend dev server..."
...
...
model/option.go
View file @
a9d3c59e
...
...
@@ -30,6 +30,7 @@ func InitOptionMap() {
common
.
OptionMap
[
"PasswordRegisterEnabled"
]
=
strconv
.
FormatBool
(
common
.
PasswordRegisterEnabled
)
common
.
OptionMap
[
"EmailVerificationEnabled"
]
=
strconv
.
FormatBool
(
common
.
EmailVerificationEnabled
)
common
.
OptionMap
[
"GitHubOAuthEnabled"
]
=
strconv
.
FormatBool
(
common
.
GitHubOAuthEnabled
)
common
.
OptionMap
[
"TelegramOAuthEnabled"
]
=
strconv
.
FormatBool
(
common
.
TelegramOAuthEnabled
)
common
.
OptionMap
[
"WeChatAuthEnabled"
]
=
strconv
.
FormatBool
(
common
.
WeChatAuthEnabled
)
common
.
OptionMap
[
"TurnstileCheckEnabled"
]
=
strconv
.
FormatBool
(
common
.
TurnstileCheckEnabled
)
common
.
OptionMap
[
"RegisterEnabled"
]
=
strconv
.
FormatBool
(
common
.
RegisterEnabled
)
...
...
@@ -62,6 +63,8 @@ func InitOptionMap() {
common
.
OptionMap
[
"TopupGroupRatio"
]
=
common
.
TopupGroupRatio2JSONString
()
common
.
OptionMap
[
"GitHubClientId"
]
=
""
common
.
OptionMap
[
"GitHubClientSecret"
]
=
""
common
.
OptionMap
[
"TelegramBotToken"
]
=
""
common
.
OptionMap
[
"TelegramBotName"
]
=
""
common
.
OptionMap
[
"WeChatServerAddress"
]
=
""
common
.
OptionMap
[
"WeChatServerToken"
]
=
""
common
.
OptionMap
[
"WeChatAccountQRCodeImageURL"
]
=
""
...
...
@@ -151,6 +154,8 @@ func updateOptionMap(key string, value string) (err error) {
common
.
GitHubOAuthEnabled
=
boolValue
case
"WeChatAuthEnabled"
:
common
.
WeChatAuthEnabled
=
boolValue
case
"TelegramOAuthEnabled"
:
common
.
TelegramOAuthEnabled
=
boolValue
case
"TurnstileCheckEnabled"
:
common
.
TurnstileCheckEnabled
=
boolValue
case
"RegisterEnabled"
:
...
...
web/src/components/SystemSetting.js
View file @
a9d3c59e
...
...
@@ -413,32 +413,6 @@ const SystemSetting = () => {
/
>
<
/Form.Group
>
<
Divider
/>
<
Header
as
=
'h3'
>
配置
Telegram
登录
<
/Header
>
<
Form
.
Group
inline
>
<
Form
.
Checkbox
checked
=
{
inputs
.
TelegramLoginEnabled
===
'true'
}
label
=
'允许通过 Telegram 进行登录'
name
=
'TelegramLoginEnabled'
onChange
=
{
handleInputChange
}
/
>
<
Form
.
Input
label
=
'Telegram Bot Token'
name
=
'TelegramBotToken'
value
=
{
inputs
.
TelegramBotToken
}
placeholder
=
'输入你的 Telegram Bot Token'
onChange
=
{
handleInputChange
}
/
>
<
Form
.
Input
label
=
'Telegram Bot 名称'
name
=
'TelegramBotName'
value
=
{
inputs
.
TelegramBotName
}
placeholder
=
'输入你的 Telegram Bot 名称'
onChange
=
{
handleInputChange
}
/
>
<
/Form.Group
>
<
Form
.
Button
onClick
=
{
submitTelegramSettings
}
>
保存
Telegram
登录设置
<
/Form.Button
>
<
Header
as
=
'h3'
>
配置邮箱域名白名单
<
Header
.
Subheader
>
用以防止恶意用户利用临时邮箱批量注册
<
/Header.Subheader
>
...
...
@@ -620,6 +594,33 @@ const SystemSetting = () => {
保存
WeChat
Server
设置
<
/Form.Button
>
<
Divider
/>
<
Header
as
=
'h3'
>
配置
Telegram
登录
<
/Header
>
<
Form
.
Group
inline
>
<
Form
.
Checkbox
checked
=
{
inputs
.
TelegramLoginEnabled
===
'true'
}
label
=
'允许通过 Telegram 进行登录'
name
=
'TelegramLoginEnabled'
onChange
=
{
handleInputChange
}
/
>
<
Form
.
Input
label
=
'Telegram Bot Token'
name
=
'TelegramBotToken'
value
=
{
inputs
.
TelegramBotToken
}
placeholder
=
'输入你的 Telegram Bot Token'
onChange
=
{
handleInputChange
}
/
>
<
Form
.
Input
label
=
'Telegram Bot 名称'
name
=
'TelegramBotName'
value
=
{
inputs
.
TelegramBotName
}
placeholder
=
'输入你的 Telegram Bot 名称'
onChange
=
{
handleInputChange
}
/
>
<
/Form.Group
>
<
Form
.
Button
onClick
=
{
submitTelegramSettings
}
>
保存
Telegram
登录设置
<
/Form.Button
>
<
Divider
/>
<
Header
as
=
'h3'
>
配置
Turnstile
<
Header
.
Subheader
>
...
...
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