From d035dc7292477056cba74781187f349958dc7442 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Sat, 10 Aug 2024 09:51:31 -0700 Subject: [PATCH] api: add session.Manager.ImpersonateUser method Helper method for calling vim.SessionManager.impersonateUser Closes #3507 --- session/manager.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/session/manager.go b/session/manager.go index e2d70a2f6..6a24fb954 100644 --- a/session/manager.go +++ b/session/manager.go @@ -291,3 +291,19 @@ func (sm *Manager) UpdateServiceMessage(ctx context.Context, message string) err return err } + +func (sm *Manager) ImpersonateUser(ctx context.Context, name string) error { + req := types.ImpersonateUser{ + This: sm.Reference(), + UserName: name, + Locale: Locale, + } + + res, err := methods.ImpersonateUser(ctx, sm.client, &req) + if err != nil { + return err + } + + sm.userSession = &res.Returnval + return nil +}