import LOGOUT_MUTATION from '@/graphql/gql/mutations/logoutUser';

export default {
  methods: {
    logout() {
      this.$apollo.mutate({
        mutation: LOGOUT_MUTATION,
      }).then(({data}) => {
        if (data.logout.success) {
          if (process.env.LOGOUT_REDIRECT_URL) {
            location.replace(`https://sso.hep-verlag.ch/logout?return_to=${process.env.LOGOUT_REDIRECT_URL}`);
          } else {
            location.replace(`/`);
          }
        }
      });
    }
  }
};
