mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-12-06 04:10:25 +08:00
创建用户的时候,可以设置开通默认功能还是全部功能
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
package users
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/systemconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/userconfigs"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
"github.com/xlzd/gotp"
|
||||
@@ -31,6 +34,7 @@ func (this *CreatePopupAction) RunPost(params struct {
|
||||
Email string
|
||||
Remark string
|
||||
ClusterId int64
|
||||
FeaturesType string
|
||||
|
||||
// OTP
|
||||
OtpOn bool
|
||||
@@ -38,6 +42,12 @@ func (this *CreatePopupAction) RunPost(params struct {
|
||||
Must *actions.Must
|
||||
CSRF *actionutils.CSRF
|
||||
}) {
|
||||
var userId int64
|
||||
|
||||
defer func() {
|
||||
this.CreateLogInfo("创建用户 %d", userId)
|
||||
}()
|
||||
|
||||
params.Must.
|
||||
Field("username", params.Username).
|
||||
Require("请输入用户名").
|
||||
@@ -97,9 +107,51 @@ func (this *CreatePopupAction) RunPost(params struct {
|
||||
return
|
||||
}
|
||||
|
||||
var userId = createResp.UserId
|
||||
userId = createResp.UserId
|
||||
|
||||
defer this.CreateLogInfo("创建用户 %d", userId)
|
||||
// 功能
|
||||
if params.FeaturesType == "default" {
|
||||
resp, err := this.RPC().SysSettingRPC().ReadSysSetting(this.AdminContext(), &pb.ReadSysSettingRequest{Code: systemconfigs.SettingCodeUserRegisterConfig})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
var config = userconfigs.DefaultUserRegisterConfig()
|
||||
if len(resp.ValueJSON) > 0 {
|
||||
err = json.Unmarshal(resp.ValueJSON, config)
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
_, err = this.RPC().UserRPC().UpdateUserFeatures(this.AdminContext(), &pb.UpdateUserFeaturesRequest{
|
||||
UserId: userId,
|
||||
FeatureCodes: config.Features,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
} else if params.FeaturesType == "all" {
|
||||
featuresResp, err := this.RPC().UserRPC().FindAllUserFeatureDefinitions(this.AdminContext(), &pb.FindAllUserFeatureDefinitionsRequest{})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
var featureCodes = []string{}
|
||||
for _, def := range featuresResp.Features {
|
||||
featureCodes = append(featureCodes, def.Code)
|
||||
}
|
||||
_, err = this.RPC().UserRPC().UpdateUserFeatures(this.AdminContext(), &pb.UpdateUserFeaturesRequest{
|
||||
UserId: userId,
|
||||
FeatureCodes: featureCodes,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// OTP
|
||||
if params.OtpOn {
|
||||
|
||||
@@ -38,6 +38,14 @@
|
||||
<p class="comment">用户发布的网站服务会自动部署到此集群。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>开通功能</td>
|
||||
<td>
|
||||
<radio name="featuresType" value="default" :v-value="'default'">默认功能</radio>
|
||||
|
||||
<radio name="featuresType" :v-value="'all'">全部功能</radio>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user