working commit
This commit is contained in:
@@ -4,20 +4,45 @@
|
||||
package account
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"mbase/pkg/client"
|
||||
"mbase/pkg/mbctl"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func (util *Util) UpdateAccount(cmd *cobra.Command, args []string) {
|
||||
//util.updateAccountParams.Filename = args[0]
|
||||
util.updateAccountParams.Username = args[0]
|
||||
res, err := util.updateAccount(util.updateAccountParams)
|
||||
printResponse(res, err)
|
||||
}
|
||||
|
||||
type updateAccountParams struct{}
|
||||
type updateAccountResult struct{}
|
||||
type UpdateAccountParams struct {
|
||||
Username string
|
||||
NewUsername string
|
||||
NewPassword string
|
||||
}
|
||||
type UpdateAccountResult struct{}
|
||||
|
||||
func (util *Util) updateAccount(params updateAccountParams) (updateAccountResult, error) {
|
||||
func (util *Util) updateAccount(params UpdateAccountParams) (UpdateAccountResult, error) {
|
||||
var err error
|
||||
res := updateAccountResult{}
|
||||
res := UpdateAccountResult{}
|
||||
|
||||
grpcConn, cli, err := client.NewClient(&util.access)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
defer grpcConn.Close()
|
||||
operParams := &mbctl.UpdateAccountParams{
|
||||
Username: params.Username,
|
||||
NewPassword: params.NewPassword,
|
||||
NewUsername: params.NewUsername,
|
||||
}
|
||||
ctx := context.Background()
|
||||
_, err = cli.UpdateAccount(ctx, operParams)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user