fix: Cannot sign-in with Gmail on desktop app

This commit is contained in:
Tom Moor
2023-05-08 19:03:56 -04:00
parent 9dfdafa116
commit ab30bfcf24
3 changed files with 71 additions and 5 deletions

View File

@@ -175,6 +175,7 @@ function Input(
labelHidden, labelHidden,
onFocus, onFocus,
onBlur, onBlur,
children,
...rest ...rest
} = props; } = props;
@@ -211,6 +212,7 @@ function Input(
{...rest} {...rest}
/> />
)} )}
{children}
</Outline> </Outline>
</label> </label>
{error && ( {error && (

View File

@@ -15,6 +15,7 @@ import Fade from "~/components/Fade";
import Flex from "~/components/Flex"; import Flex from "~/components/Flex";
import Heading from "~/components/Heading"; import Heading from "~/components/Heading";
import OutlineIcon from "~/components/Icons/OutlineIcon"; import OutlineIcon from "~/components/Icons/OutlineIcon";
import Input from "~/components/Input";
import LoadingIndicator from "~/components/LoadingIndicator"; import LoadingIndicator from "~/components/LoadingIndicator";
import PageTitle from "~/components/PageTitle"; import PageTitle from "~/components/PageTitle";
import TeamLogo from "~/components/TeamLogo"; import TeamLogo from "~/components/TeamLogo";
@@ -34,11 +35,11 @@ function Header({ config }: { config?: Config | undefined }) {
const { t } = useTranslation(); const { t } = useTranslation();
const isSubdomain = !!config?.hostname; const isSubdomain = !!config?.hostname;
if ( if (!isCloudHosted || parseDomain(window.location.origin).custom) {
!isCloudHosted || return null;
parseDomain(window.location.origin).custom || }
Desktop.isElectron()
) { if (Desktop.isElectron() && !isSubdomain) {
return null; return null;
} }
@@ -56,6 +57,8 @@ type Props = {
function Login({ children }: Props) { function Login({ children }: Props) {
const location = useLocation(); const location = useLocation();
const query = useQuery(); const query = useQuery();
const notice = query.get("notice");
const { t, i18n } = useTranslation(); const { t, i18n } = useTranslation();
const { auth } = useStores(); const { auth } = useStores();
const { config } = auth; const { config } = auth;
@@ -74,6 +77,22 @@ function Login({ children }: Props) {
setEmailLinkSentTo(email); setEmailLinkSentTo(email);
}, []); }, []);
const handleGoSubdomain = React.useCallback(async (event) => {
event.preventDefault();
const data = Object.fromEntries(new FormData(event.target));
const normalizedSubdomain = data.subdomain
.toString()
.toLowerCase()
.trim()
.replace(/^https?:\/\//, "");
const host = `https://${normalizedSubdomain}.getoutline.com`;
await Desktop.bridge.addCustomHost(host);
setTimeout(() => {
window.location.href = host;
}, 500);
}, []);
React.useEffect(() => { React.useEffect(() => {
auth.fetchConfig().catch(setError); auth.fetchConfig().catch(setError);
}, [auth]); }, [auth]);
@@ -160,6 +179,43 @@ function Login({ children }: Props) {
); );
} }
if (Desktop.isElectron() && notice === "domain-required") {
return (
<Background>
<Header config={config} />
<Centered
as="form"
onSubmit={handleGoSubdomain}
align="center"
justify="center"
column
auto
>
<Heading centered>{t("Choose workspace")}</Heading>
<Note>
{t(
"This login method requires choosing your workspace to continue"
)}
</Note>
<Flex>
<Input
name="subdomain"
style={{ textAlign: "right" }}
placeholder={t("subdomain")}
>
<Domain>.getoutline.com</Domain>
</Input>
</Flex>
<ButtonLarge type="submit" fullwidth>
{t("Continue")}
</ButtonLarge>
</Centered>
</Background>
);
}
const hasMultipleProviders = config.providers.length > 1; const hasMultipleProviders = config.providers.length > 1;
const defaultProvider = find( const defaultProvider = find(
config.providers, config.providers,
@@ -275,6 +331,11 @@ const StyledHeading = styled(Heading)`
margin: 0; margin: 0;
`; `;
const Domain = styled.div`
color: ${s("textSecondary")};
padding: 0 8px 0 0;
`;
const CheckEmailIcon = styled(EmailIcon)` const CheckEmailIcon = styled(EmailIcon)`
margin-bottom: -1.5em; margin-bottom: -1.5em;
`; `;

View File

@@ -633,6 +633,9 @@
"Custom domain setup": "Custom domain setup", "Custom domain setup": "Custom domain setup",
"Almost there": "Almost there", "Almost there": "Almost there",
"Your custom domain is successfully pointing at Outline. To complete the setup process please contact support.": "Your custom domain is successfully pointing at Outline. To complete the setup process please contact support.", "Your custom domain is successfully pointing at Outline. To complete the setup process please contact support.": "Your custom domain is successfully pointing at Outline. To complete the setup process please contact support.",
"Choose workspace": "Choose workspace",
"This login method requires choosing your workspace to continue": "This login method requires choosing your workspace to continue",
"subdomain": "subdomain",
"Check your email": "Check your email", "Check your email": "Check your email",
"A magic sign-in link has been sent to the email <em>{{ emailLinkSentTo }}</em> if an account exists.": "A magic sign-in link has been sent to the email <em>{{ emailLinkSentTo }}</em> if an account exists.", "A magic sign-in link has been sent to the email <em>{{ emailLinkSentTo }}</em> if an account exists.": "A magic sign-in link has been sent to the email <em>{{ emailLinkSentTo }}</em> if an account exists.",
"Back to login": "Back to login", "Back to login": "Back to login",