-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[dashboard] redirect anonymous users to www. #3991
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -9,7 +9,7 @@ import Menu from './components/Menu'; | |||||
import { BrowserRouter } from "react-router-dom"; | ||||||
import { Redirect, Route, Switch } from "react-router"; | ||||||
|
||||||
import { Login } from './Login'; | ||||||
import { Login, hasLoggedInBefore } from './Login'; | ||||||
import { UserContext } from './user-context'; | ||||||
import { getGitpodService } from './service/service'; | ||||||
import { shouldSeeWhatsNew, WhatsNew } from './WhatsNew'; | ||||||
|
@@ -71,6 +71,12 @@ function App() { | |||||
} | ||||||
}, [localStorage.theme]); | ||||||
|
||||||
if (window.location.pathname === '/' && window.location.hash === '' && !hasLoggedInBefore()) { | ||||||
if (window.location.host === "gitpod.io" || window.location.host === "gitpod-staging.com") { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: in development the URL is https://at-redirect-www.staging.gitpod-dev.com which won't match this logic. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. true. in the dashboard component we still don't have a proper solution for the URL mismatch in preview environments. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe something like this?
Suggested change
|
||||||
window.location.href = `https://www.${window.location.host}`; | ||||||
} | ||||||
} | ||||||
|
||||||
if (loading) { | ||||||
return <Loading /> | ||||||
} | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remove the
hasLoggedInBefore
so that you are landing on the website when you've logged out.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just learned about the
markLoggedIn
which sets a HTTP cookiegitpod-user=loggedIn
.But we already have a session cookie
gitpod-user=loggedIn
, which is managed on login/logout.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hasLoggedInBefore
checks for a Cookie which is never removed,gitpod-user=loggedIn
used to reflect the session state.WDYT of renaming the new Cookie, so it reflects that particular state? maybe something like "gitpod-logged-in-before". Maybe we can even set the provider host as value ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cookie should be called 'seen-gitpod' or so, as it just indicates the user knows gitpod (has seen the website or the app). Anyhow, we don't want to use it here, as the login state is enough. We really should redirect everyone to www once they are logged out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Roger that. The thing is, that the "login state" is fetched asynchronously. So, removing of the
gitpod-user=loggedIn
(session) cookie check, would mean that the redirect might happen in any case.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what used to work before:
gitpod/components/dashboard/src/components/create/index.tsx
Line 56 in 24f7b60