# Redirect after logout with full screen login

**URL:** <https://meta.discourse.org/t/redirect-after-logout-with-full-screen-login/109755>\
**Category:** Bug\
**Created:** [21.Февраль.2019 13:33:42 UTC](https://meta.discourse.org/t/redirect-after-logout-with-full-screen-login/109755 "2019-02-21T13:33:42Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![LeoMcA](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/leomca/32/87233_2.png) [@LeoMcA](https://meta.discourse.org/u/LeoMcA)\
**Post date:** [21.Февраль.2019 13:33:42 UTC](https://meta.discourse.org/t/redirect-after-logout-with-full-screen-login/109755/1 "2019-02-21T13:33:42Z")

</div>

This is a bit of a weird one. It requires a discourse install using “full screen login” for authentication, and the [omniauth origin param](https://github.com/omniauth/omniauth#configuring-the-origin-param) set to an external url (this is done either through a referrer or the `?origin=` param).

**Steps to reproduce** :

1. Log into a Discourse site using FSL, setting the origin to an external site  
e.g. [https://discourse.mozilla.org/auth/auth0?origin=http://example.com/](https://discourse.mozilla.org/auth/auth0?origin=http://example.com/) (I’d suggest logging in via passwordless by entering your email at the top, GitHub authentication currently requires 2FA)
2. Log out of the Discourse site after a successful login

**Result** :

You’re redirected to the external site.

**Video:**

[https://global.discourse-cdn.com/meta/original/3X/2/e/2ec6d9f4efb6e9a44f056bf79ce0c8c0e279ab9a.mp4](https://global.discourse-cdn.com/meta/original/3X/2/e/2ec6d9f4efb6e9a44f056bf79ce0c8c0e279ab9a.mp4)

**What’s going on here** :

During login, in `omniauth_callbacks_controller.rb`:

```ruby
# origin is e.g. "http://example.com/"
parsed = URI.parse(origin)
@origin = "#{parsed.path}?#{parsed.query}"
cookies[:authentication_data] = {
  destination_url: origin
}
redirect_to @origin

```

`@origin` is a host-less url, but `origin` is absolute. So in this case `@origin = "/"`

Also note, the cookie is set to the absolute `origin`, but the redirect is to the host-less `@origin`.

After logout, thanks to this in `application.html.erb` (which triggers a call to `Discourse.authenticationComplete` with the data), the user is redirected to the `destination_url` set above:

```plaintext
<%- if !current_user && cookies[:authentication_data] %>
  <meta id="data-authentication" data-authentication-data="<%= cookies.delete(:authentication_data) %>">
<%- end %>

```

So, there’s a couple of problems here:

1. That `authentcation_data` cookie seems to exist for login only. It then triggering `Discourse.authenticationComplete` on logout seems wrong to me. The cookie should probably be nuked on logout. This would prevent the post-logout redirect to `origin`.

2. The code in `omniauth_callbacks_controller.rb` is written to assume that the `origin` has the same domain as the Discourse instance, but that’s not always the case. I don’t know if the cookie-`origin`/redirect-`@origin` discrepancy is deliberate, but clearing `origin` prior to generating `@origin` if it’s not a Discourse url should fix this problem.

I’m happy to work on a PR to fix these two issues.

---

_[View the full topic](https://meta.discourse.org/t/redirect-after-logout-with-full-screen-login/109755)._
