```coffeescript
@App.controller 'UserController', ($stateParams, $window, MnoeUsers) ->
  'ngInject'
  vm = this

  # Get the user
  MnoeUsers.get($stateParams.userId).then(
    (response) ->
      vm.user = response
  )

  vm.impersonateUser = () ->
    if vm.user
      url = '/mnoe/impersonate/user/' + vm.user.id
      $window.location.href = url

  return
```

Use redirect_uri when impersonating uri
user
```coffeescript
@App.controller 'UserController', ($stateParams, $window, MnoeUsers) ->
  'ngInject'
  vm = this

  # Get the user
  MnoeUsers.get($stateParams.userId).then(
    (response) ->
      vm.user = response
  )

  vm.impersonateUser = () ->
    if vm.user
      redirect = window.encodeURIComponent("#{location.pathname}#{location.hash}")
      url = "/mnoe/impersonate/user/#{vm.user.id}?redirect_path=#{redirect}"
      $window.location.href = url

  return
```
assistant