<commit_before>App.Controllers.User = {
  initialize: function() {
    if (App.currentUser.superUser) {
      page(
        "/users/search",
        this.loadUsers.bind(this),
        this.searchUser.bind(this)
      );

      page("/exit", this.exitUser.bind(this));
    }
    page("/profile", this.profile.bind(this));
    page("/logout", this.logoutUser.bind(this));
  },

  loadUsers: function(ctx, next) {
    $.get(App.apiUrl("/users/super/idps"), function(data) {
      ctx.idps = data.payload.idps;
      ctx.roles = data.payload.roles;
      next();
    });
  },

  logoutUser: function() {
    $.get(App.apiUrl("/logout"), function() {
      App.stop();
    });
  },

  exitUser: function() {
    $.get(App.apiUrl("/users/me/switch-to-idp"), function(data) {
      App.currentUser.switchedToIdp = null;
      page("/");
    });
  },

  switchToIdp: function(idp, role, callback) {
    $.get(App.apiUrl("/users/me/switch-to-idp?idpId=" + encodeURIComponent(idp.id)), function(data) {
      App.currentUser.switchedToIdp = idp;
      page("/");
      if (callback) callback();
    });
  },

  searchUser: function(ctx) {
    App.render(App.Pages.SearchUser({idps: ctx.idps, roles: ctx.roles}));
  },

  profile: function() {
    App.render(App.Pages.Profile());
  }

};<commit_msg>Do not redirect the user away when switching idp<commit_after>App.Controllers.User = {
  initialize: function() {
    if (App.currentUser.superUser) {
      page(
        "/users/search",
        this.loadUsers.bind(this),
        this.searchUser.bind(this)
      );

      page("/exit", this.exitUser.bind(this));
    }
    page("/profile", this.profile.bind(this));
    page("/logout", this.logoutUser.bind(this));
  },

  loadUsers: function(ctx, next) {
    $.get(App.apiUrl("/users/super/idps"), function(data) {
      ctx.idps = data.payload.idps;
      ctx.roles = data.payload.roles;
      next();
    });
  },

  logoutUser: function() {
    $.get(App.apiUrl("/logout"), function() {
      App.stop();
    });
  },

  exitUser: function() {
    $.get(App.apiUrl("/users/me/switch-to-idp"), function(data) {
      App.currentUser.switchedToIdp = null;
      page("/");
    });
  },

  switchToIdp: function(idp, role, callback) {
    $.get(App.apiUrl("/users/me/switch-to-idp?idpId=" + encodeURIComponent(idp.id)), function(data) {
      App.currentUser.switchedToIdp = idp;
      page.replace(window.history.state.path);
      if (callback) callback();
    });
  },

  searchUser: function(ctx) {
    App.render(App.Pages.SearchUser({idps: ctx.idps, roles: ctx.roles}));
  },

  profile: function() {
    App.render(App.Pages.Profile());
  }

};
{'fraction_non_alphanumeric': 0.1925841846386682, 'fraction_numerical': 0.0, 'mean_word_length': 2.7988505747126435, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5628036', 'n_tokens_mistral': 937, 'n_tokens_neox': 928, 'n_words': 126}