44 lines
936 B
Go
44 lines
936 B
Go
/*
|
|
* Copyright 2026 Oleg Borodin <onborodin@gmail.com>
|
|
*/
|
|
package account
|
|
|
|
import (
|
|
"context"
|
|
|
|
"mbase/pkg/mbctl"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func (util *Util) UpdateAccount(cmd *cobra.Command, args []string) {
|
|
util.updateAccountParams.Username = args[0]
|
|
res, err := util.updateAccount(&util.updateAccountParams)
|
|
printResponse(res, err)
|
|
}
|
|
|
|
type UpdateAccountParams struct {
|
|
Username string
|
|
NewPassword string
|
|
NewUsername string
|
|
}
|
|
type UpdateAccountResult struct {
|
|
AccountID string
|
|
}
|
|
|
|
func (util *Util) updateAccount(params *UpdateAccountParams) (*UpdateAccountResult, error) {
|
|
var err error
|
|
res := &UpdateAccountResult{}
|
|
ctx := context.Background()
|
|
operParams := &mbctl.UpdateAccountParams{
|
|
Username: params.Username,
|
|
NewPassword: params.NewPassword,
|
|
NewUsername: params.NewUsername,
|
|
}
|
|
_, err = util.oper.UpdateAccount(ctx, util.operID, operParams)
|
|
if err != nil {
|
|
return res, err
|
|
}
|
|
return res, err
|
|
}
|