diff --git a/packages/client/components/AuthenticationDialog.tsx b/packages/client/components/AuthenticationDialog.tsx index 3ed5ad9f103..a53e250c3e1 100644 --- a/packages/client/components/AuthenticationDialog.tsx +++ b/packages/client/components/AuthenticationDialog.tsx @@ -1,11 +1,12 @@ import styled from '@emotion/styled' import InviteDialog from './InviteDialog' +export const AUTH_DIALOG_WIDTH = 356 const AuthenticationDialog = styled(InviteDialog)({ alignItems: 'center', paddingTop: 24, paddingBottom: 24, - width: 356 + width: AUTH_DIALOG_WIDTH }) export default AuthenticationDialog diff --git a/packages/client/components/AuthenticationPage.tsx b/packages/client/components/AuthenticationPage.tsx index dd3f6808e82..c89eb2c9be2 100644 --- a/packages/client/components/AuthenticationPage.tsx +++ b/packages/client/components/AuthenticationPage.tsx @@ -5,13 +5,15 @@ import useAtmosphere from '../hooks/useAtmosphere' import useDocumentTitle from '../hooks/useDocumentTitle' import useRouter from '../hooks/useRouter' import getValidRedirectParam from '../utils/getValidRedirectParam' +import {AUTH_DIALOG_WIDTH} from './AuthenticationDialog' import GenericAuthentication, {AuthPageSlug, GotoAuthPage} from './GenericAuthentication' import TeamInvitationWrapper from './TeamInvitationWrapper' const CopyBlock = styled('div')({ marginBottom: 48, width: 'calc(100vw - 16px)', - maxWidth: 500, + // must be no wider than the auth popup width to keep it looking clean + maxWidth: AUTH_DIALOG_WIDTH, textAlign: 'center' }) diff --git a/packages/client/components/EmailPasswordAuthForm.tsx b/packages/client/components/EmailPasswordAuthForm.tsx index ed195b49b16..d124dd8428c 100644 --- a/packages/client/components/EmailPasswordAuthForm.tsx +++ b/packages/client/components/EmailPasswordAuthForm.tsx @@ -30,6 +30,8 @@ import RaisedButton from './RaisedButton' import StyledTip from './StyledTip' interface Props { + // used to determine the coordinates of the auth popup + getOffsetTop?: () => number email: string invitationToken: string | undefined | null // is the primary login action (not secondary to Google Oauth) @@ -38,9 +40,6 @@ interface Props { goToPage?: (page: AuthPageSlug, params: string) => void } -const FieldGroup = styled('div')({ - margin: '16px 0' -}) const FieldBlock = styled('div')<{isSSO?: boolean}>(({isSSO}) => ({ margin: '0 0 1.25rem', visibility: isSSO ? 'hidden' : undefined @@ -90,7 +89,7 @@ const EmailPasswordAuthForm = forwardRef((props: Props, ref: any) => { const isInternalAuthEnabled = window.__ACTION__.AUTH_INTERNAL_ENABLED const isSSOAuthEnabled = window.__ACTION__.AUTH_SSO_ENABLED - const {isPrimary, isSignin, invitationToken, email, goToPage} = props + const {getOffsetTop, isPrimary, isSignin, invitationToken, email, goToPage} = props const {location} = useRouter() const params = new URLSearchParams(location.search) const isSSODefault = isSSOAuthEnabled && Boolean(params.get('sso')) @@ -105,7 +104,7 @@ const EmailPasswordAuthForm = forwardRef((props: Props, ref: any) => { const {fields, onChange, setDirtyField, validateField} = useForm({ email: { getDefault: () => email, - validate: validateEmail + validate: signInWithSSOOnly ? undefined : validateEmail }, password: { getDefault: () => '', @@ -150,6 +149,7 @@ const EmailPasswordAuthForm = forwardRef((props: Props, ref: any) => { const domain = getSSODomainFromEmail(email)! const validSSOURL = domain === ssoDomain && ssoURL const isProbablySSO = isSSO || !fields.password.value || validSSOURL + const top = getOffsetTop?.() || 56 let optimisticPopup if (isProbablySSO) { // Safari blocks all calls to window.open that are not triggered SYNCHRONOUSLY from an event @@ -164,7 +164,7 @@ const EmailPasswordAuthForm = forwardRef((props: Props, ref: any) => { optimisticPopup = window.open( '', 'SSO', - getOAuthPopupFeatures({width: 385, height: 550, top: 64}) + getOAuthPopupFeatures({width: 385, height: 576, top}) ) } const url = validSSOURL || (await getSSOUrl(atmosphere, email)) @@ -173,7 +173,7 @@ const EmailPasswordAuthForm = forwardRef((props: Props, ref: any) => { return false } submitMutation() - const response = await getTokenFromSSO(url) + const response = await getTokenFromSSO(url, top) if ('error' in response) { onError(new Error(response.error || 'Error logging in')) return true @@ -198,6 +198,7 @@ const EmailPasswordAuthForm = forwardRef((props: Props, ref: any) => { const onSubmit = async (e: React.FormEvent) => { e.preventDefault() if (submitting) return + onCompleted() setDirtyField() const {email: emailRes, password: passwordRes} = validateField() if (emailRes.error) return @@ -244,8 +245,8 @@ const EmailPasswordAuthForm = forwardRef((props: Props, ref: any) => {
{error && } {isSSO && submitting && Continue through the login popup} - - +
+ { /> )} - +