Merge pull request #1496 from Bliod-Cook/feat-linuxdo-minumum-trust-level
feat: allow admin to restrict the minimum linuxdo trust level to register
This commit is contained in:
@@ -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 = ""
|
||||||
|
|||||||
@@ -220,21 +220,29 @@ func LinuxdoOAuth(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if common.RegisterEnabled {
|
if common.RegisterEnabled {
|
||||||
user.Username = "linuxdo_" + strconv.Itoa(model.GetMaxUserId()+1)
|
if linuxdoUser.TrustLevel >= common.LinuxDOMinimumTrustLevel {
|
||||||
user.DisplayName = linuxdoUser.Name
|
user.Username = "linuxdo_" + strconv.Itoa(model.GetMaxUserId()+1)
|
||||||
user.Role = common.RoleCommonUser
|
user.DisplayName = linuxdoUser.Name
|
||||||
user.Status = common.UserStatusEnabled
|
user.Role = common.RoleCommonUser
|
||||||
|
user.Status = common.UserStatusEnabled
|
||||||
|
|
||||||
affCode := session.Get("aff")
|
affCode := session.Get("aff")
|
||||||
inviterId := 0
|
inviterId := 0
|
||||||
if affCode != nil {
|
if affCode != nil {
|
||||||
inviterId, _ = model.GetUserIdByAffCode(affCode.(string))
|
inviterId, _ = model.GetUserIdByAffCode(affCode.(string))
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := user.Insert(inviterId); err != nil {
|
if err := user.Insert(inviterId); err != nil {
|
||||||
|
c.JSON(http.StatusOK, gin.H{
|
||||||
|
"success": false,
|
||||||
|
"message": err.Error(),
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
c.JSON(http.StatusOK, gin.H{
|
c.JSON(http.StatusOK, gin.H{
|
||||||
"success": false,
|
"success": false,
|
||||||
"message": err.Error(),
|
"message": "Linux DO 信任等级未达到管理员设置的最低信任等级",
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,46 +41,47 @@ func GetStatus(c *gin.Context) {
|
|||||||
cs := console_setting.GetConsoleSetting()
|
cs := console_setting.GetConsoleSetting()
|
||||||
|
|
||||||
data := gin.H{
|
data := gin.H{
|
||||||
"version": common.Version,
|
"version": common.Version,
|
||||||
"start_time": common.StartTime,
|
"start_time": common.StartTime,
|
||||||
"email_verification": common.EmailVerificationEnabled,
|
"email_verification": common.EmailVerificationEnabled,
|
||||||
"github_oauth": common.GitHubOAuthEnabled,
|
"github_oauth": common.GitHubOAuthEnabled,
|
||||||
"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,
|
||||||
"telegram_oauth": common.TelegramOAuthEnabled,
|
"linuxdo_minimum_trust_level": common.LinuxDOMinimumTrustLevel,
|
||||||
"telegram_bot_name": common.TelegramBotName,
|
"telegram_oauth": common.TelegramOAuthEnabled,
|
||||||
"system_name": common.SystemName,
|
"telegram_bot_name": common.TelegramBotName,
|
||||||
"logo": common.Logo,
|
"system_name": common.SystemName,
|
||||||
"footer_html": common.Footer,
|
"logo": common.Logo,
|
||||||
"wechat_qrcode": common.WeChatAccountQRCodeImageURL,
|
"footer_html": common.Footer,
|
||||||
"wechat_login": common.WeChatAuthEnabled,
|
"wechat_qrcode": common.WeChatAccountQRCodeImageURL,
|
||||||
"server_address": setting.ServerAddress,
|
"wechat_login": common.WeChatAuthEnabled,
|
||||||
"price": setting.Price,
|
"server_address": setting.ServerAddress,
|
||||||
"stripe_unit_price": setting.StripeUnitPrice,
|
"price": setting.Price,
|
||||||
"min_topup": setting.MinTopUp,
|
"stripe_unit_price": setting.StripeUnitPrice,
|
||||||
"stripe_min_topup": setting.StripeMinTopUp,
|
"min_topup": setting.MinTopUp,
|
||||||
"turnstile_check": common.TurnstileCheckEnabled,
|
"stripe_min_topup": setting.StripeMinTopUp,
|
||||||
"turnstile_site_key": common.TurnstileSiteKey,
|
"turnstile_check": common.TurnstileCheckEnabled,
|
||||||
"top_up_link": common.TopUpLink,
|
"turnstile_site_key": common.TurnstileSiteKey,
|
||||||
"docs_link": operation_setting.GetGeneralSetting().DocsLink,
|
"top_up_link": common.TopUpLink,
|
||||||
"quota_per_unit": common.QuotaPerUnit,
|
"docs_link": operation_setting.GetGeneralSetting().DocsLink,
|
||||||
"display_in_currency": common.DisplayInCurrencyEnabled,
|
"quota_per_unit": common.QuotaPerUnit,
|
||||||
"enable_batch_update": common.BatchUpdateEnabled,
|
"display_in_currency": common.DisplayInCurrencyEnabled,
|
||||||
"enable_drawing": common.DrawingEnabled,
|
"enable_batch_update": common.BatchUpdateEnabled,
|
||||||
"enable_task": common.TaskEnabled,
|
"enable_drawing": common.DrawingEnabled,
|
||||||
"enable_data_export": common.DataExportEnabled,
|
"enable_task": common.TaskEnabled,
|
||||||
"data_export_default_time": common.DataExportDefaultTime,
|
"enable_data_export": common.DataExportEnabled,
|
||||||
"default_collapse_sidebar": common.DefaultCollapseSidebar,
|
"data_export_default_time": common.DataExportDefaultTime,
|
||||||
"enable_online_topup": setting.PayAddress != "" && setting.EpayId != "" && setting.EpayKey != "",
|
"default_collapse_sidebar": common.DefaultCollapseSidebar,
|
||||||
"enable_stripe_topup": setting.StripeApiSecret != "" && setting.StripeWebhookSecret != "" && setting.StripePriceId != "",
|
"enable_online_topup": setting.PayAddress != "" && setting.EpayId != "" && setting.EpayKey != "",
|
||||||
"mj_notify_enabled": setting.MjNotifyEnabled,
|
"enable_stripe_topup": setting.StripeApiSecret != "" && setting.StripeWebhookSecret != "" && setting.StripePriceId != "",
|
||||||
"chats": setting.Chats,
|
"mj_notify_enabled": setting.MjNotifyEnabled,
|
||||||
"demo_site_enabled": operation_setting.DemoSiteEnabled,
|
"chats": setting.Chats,
|
||||||
"self_use_mode_enabled": operation_setting.SelfUseModeEnabled,
|
"demo_site_enabled": operation_setting.DemoSiteEnabled,
|
||||||
"default_use_auto_group": setting.DefaultUseAutoGroup,
|
"self_use_mode_enabled": operation_setting.SelfUseModeEnabled,
|
||||||
"pay_methods": setting.PayMethods,
|
"default_use_auto_group": setting.DefaultUseAutoGroup,
|
||||||
"usd_exchange_rate": setting.USDExchangeRate,
|
"pay_methods": setting.PayMethods,
|
||||||
|
"usd_exchange_rate": setting.USDExchangeRate,
|
||||||
|
|
||||||
// 面板启用开关
|
// 面板启用开关
|
||||||
"api_info_enabled": cs.ApiInfoEnabled,
|
"api_info_enabled": cs.ApiInfoEnabled,
|
||||||
|
|||||||
@@ -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":
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ const SystemSetting = () => {
|
|||||||
LinuxDOOAuthEnabled: '',
|
LinuxDOOAuthEnabled: '',
|
||||||
LinuxDOClientId: '',
|
LinuxDOClientId: '',
|
||||||
LinuxDOClientSecret: '',
|
LinuxDOClientSecret: '',
|
||||||
|
LinuxDOMinimumTrustLevel: '',
|
||||||
ServerAddress: '',
|
ServerAddress: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -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 = () => {
|
|||||||
<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={12} lg={12} xl={12}>
|
<Col xs={24} sm={24} md={10} 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={12} lg={12} xl={12}>
|
<Col xs={24} sm={24} md={10} 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 = () => {
|
|||||||
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 设置')}
|
||||||
|
|||||||
Reference in New Issue
Block a user