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
|
package users
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
"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/actions"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
"github.com/xlzd/gotp"
|
"github.com/xlzd/gotp"
|
||||||
@@ -22,15 +25,16 @@ func (this *CreatePopupAction) RunGet(params struct{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *CreatePopupAction) RunPost(params struct {
|
func (this *CreatePopupAction) RunPost(params struct {
|
||||||
Username string
|
Username string
|
||||||
Pass1 string
|
Pass1 string
|
||||||
Pass2 string
|
Pass2 string
|
||||||
Fullname string
|
Fullname string
|
||||||
Mobile string
|
Mobile string
|
||||||
Tel string
|
Tel string
|
||||||
Email string
|
Email string
|
||||||
Remark string
|
Remark string
|
||||||
ClusterId int64
|
ClusterId int64
|
||||||
|
FeaturesType string
|
||||||
|
|
||||||
// OTP
|
// OTP
|
||||||
OtpOn bool
|
OtpOn bool
|
||||||
@@ -38,6 +42,12 @@ func (this *CreatePopupAction) RunPost(params struct {
|
|||||||
Must *actions.Must
|
Must *actions.Must
|
||||||
CSRF *actionutils.CSRF
|
CSRF *actionutils.CSRF
|
||||||
}) {
|
}) {
|
||||||
|
var userId int64
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
this.CreateLogInfo("创建用户 %d", userId)
|
||||||
|
}()
|
||||||
|
|
||||||
params.Must.
|
params.Must.
|
||||||
Field("username", params.Username).
|
Field("username", params.Username).
|
||||||
Require("请输入用户名").
|
Require("请输入用户名").
|
||||||
@@ -97,9 +107,51 @@ func (this *CreatePopupAction) RunPost(params struct {
|
|||||||
return
|
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
|
// OTP
|
||||||
if params.OtpOn {
|
if params.OtpOn {
|
||||||
|
|||||||
@@ -38,6 +38,14 @@
|
|||||||
<p class="comment">用户发布的网站服务会自动部署到此集群。</p>
|
<p class="comment">用户发布的网站服务会自动部署到此集群。</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>开通功能</td>
|
||||||
|
<td>
|
||||||
|
<radio name="featuresType" value="default" :v-value="'default'">默认功能</radio>
|
||||||
|
|
||||||
|
<radio name="featuresType" :v-value="'all'">全部功能</radio>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
Reference in New Issue
Block a user