Fix up login/signing paths and buttons

environments/review-ditto-auth-csh1vn/deployments/4454
Alex Gleason 2024-03-18 13:44:34 -05:00
rodzic 7cfbf22b27
commit e131467af9
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
3 zmienionych plików z 26 dodań i 5 usunięć

Wyświetl plik

@ -4,9 +4,9 @@ import { Redirect } from 'react-router-dom';
import { logIn, verifyCredentials, switchAccount } from 'soapbox/actions/auth';
import { fetchInstance } from 'soapbox/actions/instance';
import { closeModal } from 'soapbox/actions/modals';
import { closeModal, openModal } from 'soapbox/actions/modals';
import { BigCard } from 'soapbox/components/big-card';
import { useAppDispatch, useAppSelector } from 'soapbox/hooks';
import { useAppDispatch, useAppSelector, useFeatures } from 'soapbox/hooks';
import { getRedirectUrl } from 'soapbox/utils/redirect';
import { isStandalone } from 'soapbox/utils/state';
@ -21,6 +21,7 @@ const LoginPage = () => {
const me = useAppSelector((state) => state.me);
const standalone = useAppSelector((state) => isStandalone(state));
const { nostrSignup } = useFeatures();
const token = new URLSearchParams(window.location.search).get('token');
@ -62,6 +63,11 @@ const LoginPage = () => {
event.preventDefault();
};
if (nostrSignup) {
setTimeout(() => dispatch(openModal('NOSTR_LOGIN')), 100);
return <Redirect to='/' />;
}
if (standalone) return <Redirect to='/login/external' />;
if (shouldRedirect) {

Wyświetl plik

@ -1,15 +1,24 @@
import React from 'react';
import { FormattedMessage } from 'react-intl';
import { Redirect } from 'react-router-dom';
import { openModal } from 'soapbox/actions/modals';
import { BigCard } from 'soapbox/components/big-card';
import { Text } from 'soapbox/components/ui';
import { useInstance, useRegistrationStatus } from 'soapbox/hooks';
import { useAppDispatch, useFeatures, useInstance, useRegistrationStatus } from 'soapbox/hooks';
import RegistrationForm from './registration-form';
const RegistrationPage: React.FC = () => {
const instance = useInstance();
const { isOpen } = useRegistrationStatus();
const { nostrSignup } = useFeatures();
const dispatch = useAppDispatch();
if (nostrSignup) {
setTimeout(() => dispatch(openModal('NOSTR_SIGNUP')), 100);
return <Redirect to='/' />;
}
if (!isOpen) {
return (

Wyświetl plik

@ -3,10 +3,11 @@ import { FormattedMessage } from 'react-intl';
import { openModal } from 'soapbox/actions/modals';
import { Button, Stack, Text } from 'soapbox/components/ui';
import { useAppDispatch, useAppSelector, useInstance, useRegistrationStatus } from 'soapbox/hooks';
import { useAppDispatch, useAppSelector, useFeatures, useInstance, useRegistrationStatus } from 'soapbox/hooks';
const SignUpPanel = () => {
const instance = useInstance();
const { nostrSignup } = useFeatures();
const { isOpen } = useRegistrationStatus();
const me = useAppSelector((state) => state.me);
const dispatch = useAppDispatch();
@ -25,7 +26,12 @@ const SignUpPanel = () => {
</Text>
</Stack>
<Button theme='primary' block onClick={() => dispatch(openModal('NOSTR_SIGNUP'))}>
<Button
theme='primary'
onClick={nostrSignup ? () => dispatch(openModal('NOSTR_SIGNUP')) : undefined}
to={nostrSignup ? undefined : '/signup'}
block
>
<FormattedMessage id='account.register' defaultMessage='Sign up' />
</Button>
</Stack>