2022-01-05 10:45:28 +08:00
|
|
|
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
|
|
|
|
|
|
|
|
|
|
package users
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
2023-06-30 18:08:30 +08:00
|
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
|
2022-01-05 10:45:28 +08:00
|
|
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
|
|
|
|
"github.com/iwind/TeaGo/actions"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type VerifyPopupAction struct {
|
|
|
|
|
actionutils.ParentAction
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (this *VerifyPopupAction) RunGet(params struct {
|
|
|
|
|
UserId int64
|
|
|
|
|
}) {
|
|
|
|
|
this.Data["userId"] = params.UserId
|
|
|
|
|
|
|
|
|
|
this.Show()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (this *VerifyPopupAction) RunPost(params struct {
|
|
|
|
|
UserId int64
|
|
|
|
|
Result string
|
|
|
|
|
RejectReason string
|
|
|
|
|
|
|
|
|
|
Must *actions.Must
|
|
|
|
|
CSRF *actionutils.CSRF
|
|
|
|
|
}) {
|
2023-06-30 18:08:30 +08:00
|
|
|
defer this.CreateLogInfo(codes.User_LogVerifyUser, params.UserId, params.Result)
|
2022-01-05 10:45:28 +08:00
|
|
|
|
|
|
|
|
if params.Result == "pass" {
|
|
|
|
|
params.RejectReason = ""
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_, err := this.RPC().UserRPC().VerifyUser(this.AdminContext(), &pb.VerifyUserRequest{
|
|
|
|
|
UserId: params.UserId,
|
|
|
|
|
IsRejected: params.Result == "reject" || params.Result == "delete",
|
|
|
|
|
RejectReason: params.RejectReason,
|
|
|
|
|
})
|
|
|
|
|
if err != nil {
|
|
|
|
|
this.ErrorPage(err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if params.Result == "delete" {
|
|
|
|
|
_, err = this.RPC().UserRPC().DeleteUser(this.AdminContext(), &pb.DeleteUserRequest{UserId: params.UserId})
|
|
|
|
|
if err != nil {
|
|
|
|
|
this.ErrorPage(err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.Success()
|
|
|
|
|
}
|