<commit_before>package EnsEMBL::Users::Command::Account::Logout;

### Command to clear user cookies
### @author hr5

use strict;

use base qw(EnsEMBL::Users::Command::Account);

sub process {
  my $self    = shift;
  my $hub     = $self->hub;

  # clears cookies & saved user object
  $hub->user->deauthorise;

  return $self->ajax_redirect($hub->type eq 'Account' ? '/' : $hub->referer->{'absolute_url'}, {}, '', 'page');
}

1;<commit_msg>$hub->type will always be 'Account' in this case. Check referer instead.<commit_after>package EnsEMBL::Users::Command::Account::Logout;

### Command to clear user cookies
### @author hr5

use strict;

use base qw(EnsEMBL::Users::Command::Account);

sub process {
  my $self    = shift;
  my $hub     = $self->hub;

  # clears cookies & saved user object
  $hub->user->deauthorise;

  # redirect to the right page depending upon the referer
  my $referer = $hub->referer;

  return $self->ajax_redirect($referer->{'external'} || $referer->{'ENSEMBL_TYPE'} eq 'Account' ? '/' : $referer->{'absolute_url'}, {}, '', 'page');
}

1;
{'fraction_non_alphanumeric': 0.17917448405253283, 'fraction_numerical': 0.00375234521575985, 'mean_word_length': 4.5, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '3829747', 'n_tokens_mistral': 366, 'n_tokens_neox': 358, 'n_words': 92}