/* @ngInject */
module.exports = function ($scope, $state, AuthService, AUTH_EVENTS, $http) {
  $scope.currentUser = null;

  $scope.updateCurrentUser = function () {
    $scope.currentUser = AuthService.getCurrentUser();
    $scope.updateCurrentUserHeaders();
  };

  $scope.updateCurrentUserHeaders = function () {
    var token, email;
    if ($scope.currentUser) {
      token = $scope.currentUser.access_token;
      email = $scope.currentUser.email;
    }
    var defaultHeaders = {
      "Accept": "application/json",
      "X-User-Token": token,
      "X-User-Email": email,
    };
    $http.defaults.headers.common = defaultHeaders;
  };

  $scope.$on(AUTH_EVENTS.loginSuccess, function () {
    $scope.updateCurrentUser();
    if ($scope.currentUser.force_password_reset === true) {
      $state.go('layout.user_settings');
    } else {
      $state.go('layout.group.rounds', {groupId: 1});
    }
  });

  $scope.$on(AUTH_EVENTS.logoutSuccess, function () {
    $scope.updateCurrentUser();
  });

  $scope.updateCurrentUser();
};

@@ -814,22 +814,60 @@
 out.
-user_settings'
+person.profile', %7B personId: $scope.currentUser.id %7D
 );%0A 

update router navigation on force_password_reset